[Solved] Checkboxes in a simple form are not displayed

Sebish Asks: Checkboxes in a simple form are not displayed
I have a simple form in a custom module that works well and is displaying my select as it should.

Code:
$form = Drupal::formBuilder()->getForm('DrupalefqFormFilterForm');
$form["container"] =  array(
    'categories' => array(
        '#title' => t('Select a Category'),
        '#type' => 'select',
        '#options' =>  array(
            1 => t('Option 1'),
            2 => t('Option 2'),
            3 => t('Option 3'),
        )
    )
);

I would like to change Select for Checkboxes. According to this, “Checkboxes” structure is the same as per “Select”. But when I change '#type' => 'select' for '#type' => 'checkboxes' there are no checkboxes created and I got the 2 following warnings:

Code:
Notice: Undefined index: #title_display in DrupalCoreRenderElementCheckboxes::preRenderCompositeFormElement() (line 20 of core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php).
Notice: Undefined index: #id in DrupalCoreRenderElementCheckboxes::preRenderCompositeFormElement() (line 30 of core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php).

Adding these in an array makes the notice messages disappear but the checkboxes are still not showing.

Any idea of what’s going on ?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.