Skip to content

Conversation

@shacky
Copy link

@shacky shacky commented Sep 17, 2020

If there is a validation error with any of fields in form hasMany field changes keys of new rows from "new_X" to "new__LA_KEY_". This way no validation error is displayed and on the second submit a couple of rows will be merged to one because every new row has the same key: "new__LA_KEY_".

Sample form code:

$form->text('some_required_field')->rules('required');
$form->hasMany('some_relation','Relation',function($form) {
  $form->text('some_relation_required_field')->rules('required');  
});

Now if you left any of this fields empty, form won't validate.
some_relation_required_field will change input name from some_relation_required_field[new_1] to some_relation_required_field[new__LA_KEY_].
If you left some_relation_required_field empty error won't be displayed, because form input name has changed.

Pull request resolves this issue. It's not very elegant, but I couldn't find another way to fix this issue.

@shacky
Copy link
Author

shacky commented Sep 17, 2020

It fixes issues #4758 and #4612

@stale
Copy link

stale bot commented Nov 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

1 similar comment
@stale
Copy link

stale bot commented Jan 18, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 18, 2021
@stale stale bot closed this Feb 2, 2021
@emacaste
Copy link

emacaste commented Aug 5, 2021

@z-song why did you not merge this pr? It solves well a very annoyng bug.
Right now the only solution is to extend the base hasMany field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants