You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, sometimes there are two or more forms in one page. They can contain fields with the same name.
For example, there is a table of articles and each article row contains <form method="post"> with publication_date and a button which publishes the article. It is not possible to use old() method for the publication_date because it would change all such fields of all articles after failed validation.
One workaround is to suffix publication_date with ID of the article: publication_date . '_' . $article->id however that is not very good solution if there are multiple fields, also validation is problematic.
I propose to modify the old() method or create a new method which would accept $validationBag name and could be used with already existing validation mechanism $request->validateWithBag('publish-' . $article->id). Then after failed validation, only one old() function would actually produced old data. Other old() functions would use default values.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, sometimes there are two or more forms in one page. They can contain fields with the same name.
For example, there is a table of articles and each article row contains
<form method="post">
withpublication_date
and a button which publishes the article. It is not possible to use old() method for thepublication_date
because it would change all such fields of all articles after failed validation.One workaround is to suffix
publication_date
with ID of the article:publication_date . '_' . $article->id
however that is not very good solution if there are multiple fields, also validation is problematic.I propose to modify the old() method or create a new method which would accept $validationBag name and could be used with already existing validation mechanism
$request->validateWithBag('publish-' . $article->id)
. Then after failed validation, only oneold()
function would actually produced old data. Otherold()
functions would use default values.Beta Was this translation helpful? Give feedback.
All reactions