Laminas Collection not showing full element count on Form Edit view

Viewed 27

I've been upgrading from ZF2 to Laminas. I've noticed that ZF3/Laminas added some new javascript functionality to add element templates to collections; 'should_create_template' = true. This would allow you to add elements; in a perfect world. I can not use it that way, because I am applying SELECT2 javascript code to my dropdown selection. I'm also using TWIG templates.

I'm wanting to display the Form's Fieldset's collection in the old ZF2 way, where it would just show all 4 (count = 4), regardless of the selections. Currently, I have an issue on the Edit Form where it only shows elements that are filled in (selected). So, if only 2 elements are related, then it only shows 2 dropdown selections. Elements 3 and 4, which would normally be used to add additional relationships, are not shown.

This is the way that it's currently showing on Edit:

enter image description here

This is the way I need it to show on Edit: enter image description here

Form Collection Element:

$this->add(array(
    'name' => 'patientDiagnosis',  // Must match name of property in model/mapping
    'type' => \Laminas\Form\Element\Collection::class,
    'options' => array(
        'label'          => 'Diagnosis',
        'allow_add'      => true,
        'allow_remove'   => true,
        'count'          => 4,
        'target_element' => new PatientDiagnosisFieldset($objectManager)
    )
));
0 Answers
Related