kristijanhusak / laravel-form-builder

Laravel Form builder for version 5+!
https://packagist.org/packages/kris/laravel-form-builder
MIT License
1.69k stars 295 forks source link

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

Open SebTM opened 7 years ago

SebTM commented 7 years ago

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!

kristijanhusak commented 7 years ago

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

SebTM commented 7 years ago

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?

salkhwlani commented 7 years ago

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

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