Skip to content

Multiple checkboxes in plain subform get double [][] #324

Open
@rudiedirkx

Description

@rudiedirkx

My form simplified:

// Prepare subform
$taco_test = $this->formBuilder->plain();
$taco_test->add('professions', 'choice', [
  'label' => trans('report.taco_test.professions'),
  'choices' => $favorites_options,
  'multiple' => TRUE,
  'expanded' => TRUE,
]);

// Add subform to parent
$this->add('taco_test', 'form', [
  'label' => trans('report.taco_test.taco_test'),
  'class' => $taco_test, // the plain form object
]);

So the checkboxes live at form.taco_test.professions, so a single checkbox should be at eg. form.taco_test.professions.66.

The resulting checkboxes have name="taco_test[professions][][]", with a double [][]. Their values are correct.

I know the last [] are added in ChoiceType::buildCheckableChildren(), but maybe it's the first [] that's actually wrong. I've no idea where that comes from.

I'm using 1.6.50 and I'm having some dependency problems, so I can't update in this context to try newer version, but the ChoiceType code seems to be the same in HEAD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions