laravel-form-builder icon indicating copy to clipboard operation
laravel-form-builder copied to clipboard

Checkbox get two "[][]" if using modify

Open SebTM opened this issue 8 years ago • 3 comments

Hello,

if I use modify on field-type "choice" I get html like "fieldName[][]" as name attribute. Here is my controller-code to reproduce:

public function testModify()
    {
        $form = FormBuilder::plain()
            ->add('name', 'text')
            ->add('test', 'choice', [
                'choices' => ['en' => 'English', 'fr' => 'French'],
                'choice_options' => [
                    'wrapper' => ['class' => 'choice-wrapper'],
                    'label_attr' => ['class' => 'label-class'],
                ],
                'expanded' => true,
                'multiple' => true
            ]);

        $form->modify('test', 'choice', [
            'rules' => 'required',
        ]);

        $form->add('submit', 'submit');

        return View::make('cdou.form', ['form' => $form]);
    }

Best Regards!

SebTM avatar Jan 18 '17 12:01 SebTM

@SebTM please avoid modify method, since there are some issues with it https://github.com/kristijanhusak/laravel-form-builder/issues/237

kristijanhusak avatar Jan 18 '17 13:01 kristijanhusak

Hello,

I understand that there are currently issues with "modify". I really need to use the method as this example is only to reproduce the issue. I have a complex crud-system which uses form-classes to provide the basic-functionallity but the validation-configuration comes from another configuration.

Is there any possibility to archiv/fix this?

SebTM avatar Jan 18 '17 14:01 SebTM

@SebTM I have the same problem, as quick fix pass "tmp" to options field to avoid add [] multi times

'tmp' => ['multipleBracesSet' => true],

salkhwlani avatar Jan 30 '17 15:01 salkhwlani