After
I got curious if there are easier solutions to my coding mess. So 3 problems and my solutions (the mess) and I hope there are easier ways. (The first is a real problem with the checkboxes so that will probably result in a resolved)
1. Add a searchfield above a list of checkboxes
I had a few problems with the default code: ((form}}
- I never see checkboxes
- the search field is never shown at a convenient location in the html and associated with the correct list (can only add this is a manual template)
- I lost my code that showed all checked list items on top of the list (css only) I will add it if I find it again)
the list of phonenumbers resulting from:
telephoneNumbers = models.ManyToManyField( to=PhoneNumber
                                    ,related_name="person"
                                   )
shows it as html not as checkboxes .
I hoped the widget CheckboxSelectMultiple would solve that
class Meta:
        model = Entity
        fields = "__all__"
        widgets = {
            'telephoneNumbers': forms.CheckboxSelectMultiple(attrs=
            {
                'type': "checkbox",
            }),
      }
But that does not change the elements into a checkbox even though the widget name implies it.
Adding the following code works
class Personform(ModelForm):
    telephoneNumbers = forms.ModelMultipleChoiceField(
            queryset = PhoneNumber.objects.all(),
            widget = forms.CheckboxSelectMultiple(attrs=
                {
                }
            ),
        )
but that means I have 'redefined' the field in the form (dont know the right word describing the problem)
So how can I create a checkbox list and how can I place the searchfield in a usefull place? Is that even possible without creating a total manual template for that?
2: All manual templates
I had to create templates for some fields and (until yesterday) that resulted in me creating a template for each field. For instance the following code for the fuull name of a person consisting of 3 form fields
<form method="post" class="edit">
   {% csrf_token %}
   {% include "MyNetwork/form/person/full_name_fields_form.html" %}
   {% include "MyNetwork/form/person/gender_field_form.html" %}
   {% include "MyNetwork/form/person/date_of_birth_field_form.html" %}
 </form>
with:
{% load i18n %}
<div class="form-element-group">
  <label for="{{ form.familyName.id_for_label }}">{% translate "full name"%}</label>
  <span>
  {{ form.firstName }}
  {{ form.nameAffix }}
  {{ form.familyName }}
  </span>
  {% if form.firstName.help_text or form.nameAffix.help_text or form.familyName.help_text %}
  <div class="help">
     {{ form.firstName.help_text }} 
     {{ form.nameAffix.help_text }}
     {{ form.familyName.help_text }}
  </div>
  {% endif %}
  {% if form.firstName.errors or form.nameAffix.errors or form.familyName.errors %}
  <div class="errors">
    {{ form.firstName.errors }}
    {{ form.nameAffix.errors }}
    {{ form.familyName.errors }}    
  </div>
  {% endif %}
</div>
Because I included one field this way it seams I need to add all fields this way. And because the default template code does not perform like expected (for me) that means a lot of templates to add with include.
And worse… a lot to correct if I make the same mistake in every template  And I did that to many times. I expected
 And I did that to many times. I expected {{ person_form.firstName }} to create all associated fields like label, formfield errors and help_text but it only adds the form field.`
A bit clearer. I expected the result from a template like this:
{% load i18n %}
<div class="formFieldWrapper">
  <label for="{{ form.firstName.id_for_label }}">{{ form.firstName.label }}</label>
  {{ form.firstName }}
  {% if form.firstName.help_text %}
    <div class="help">
    {{ form.firstName.help_text }} 
    </div>
  {% endif %}
  {% if form.firstName.errors %}
    <div class="errors">
      {{ form.firstName.errors }}
    </div>
  {% endif %}
</div>
But I only get the form field:
<input type="text" name="firstName" placeholder="First name" size="30" maxlength="60" class="textinput form-control" id="id_firstName">
Crispy came to the rescue though (I found out yesterday) with
{{person_form.firstName|as_crispy_field}}
But is there a way without crispy to do this the easy way?.. add all with one commment. online people suggest {{person_form.firstName}} should do that but sadly it doesnt. Can it be easyer then the crispy solution?
3. place multiple fields in a row
I want to place the name fields in a row like

With
{% load i18n %}
<div class="form-element-group">
  <label for="{{ form.familyName.id_for_label }}">{% translate "full name"%}</label>
  <span>
  {{ form.firstName }}
  {{ form.nameAffix }}
  {{ form.familyName }}
  </span>
  {% if form.firstName.help_text or form.nameAffix.help_text or form.familyName.help_text %}
  <div class="help">
     {{ form.firstName.help_text }} 
     {{ form.nameAffix.help_text }}
     {{ form.familyName.help_text }}
  </div>
  {% endif %}
  {% if form.firstName.errors or form.nameAffix.errors or form.familyName.errors %}
  <div class="errors">
    {{ form.firstName.errors }}
    {{ form.nameAffix.errors }}
    {{ form.familyName.errors }}    
  </div>
  {% endif %}
</div>
it works and with crispy I might have a bit different but same solution:
<div class="row">
    {{ person_form.firstName|as_crispy_field}}
    {{ person_form.nameAffix|as_crispy_field}}
    {{ person_form.familyName|as_crispy_field}}
</div>
the solution with FormHelper did nothing. I probably did something wrong:
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column('firstName', css_class='test'),
                Column('nameAffix', css_class='test'),
                Column('familyName', css_class='test'),
                css_class='test2'
            ),
            'dateOfBirth',
            'gender',
        )
What is the best solution here?
