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

Old options will remain

Open ukeloop opened this issue 2 years ago • 3 comments

If I want to change rules and the number of rules is too small, the old rules will remain.

$form = $this->plain()
    ->add(
        'email',
        'email',
        [
            'rules' => [
                'rule_a',
                'rule_b',
                'rule_c',
            ],
        ],
    );

$form->modify(
    'email',
    'email',
    [
        'rules' => [
            'rule_d',
        ],
    ],
);

Modified rules is

$form->email->getOption('rules');
// [
//     'rule_d',
//     'rule_b',
//     'rule_c',
// ],

But I expect

$form->email->getOption('rules');
// [
//     'rule_d',
// ],

ukeloop avatar Mar 05 '22 18:03 ukeloop

It seems that was intentional..? Kinda? See #577 - I'm lost...

rudiedirkx avatar Mar 05 '22 22:03 rudiedirkx

I had missed out on that PR. Thanks for letting me know.

However, I think this problem applies to all options of type list, such as choice.

I'm just as eager to make this project better as you are.

Thank.

ukeloop avatar Mar 06 '22 03:03 ukeloop

I'm just as eager to make this project better as you are.

We need a few rewrites. No more ParentType (choice) for select/radios/checkboxes, better options merging, better collection value/models, fixing the form field, probably more, lots of BC breaks.

rudiedirkx avatar Mar 06 '22 22:03 rudiedirkx