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
The title must always exist and be at least 10 chars long.
The description may be empty.
Expected behaviour:
When loading the edit form, I expect the form to show the values of $title and $description in the fields.
Whenever submitting a the form with invalid field-values, I expect the submitted values to be shown in the fields, instead of the values of $title and $description.
Problem:
This works only when submitting non-empty strings!
When submitting an empty-string, it's like Former handles it like the field-hasn't even been submitted, and therefore uses the value given by $title or $description instead.
I thought Former was able to do this "smart", and take the value($variable) value only if the posted data does not contain the field. But it seems Former is taking the variables value also when the submitted was empty.
Why is this a problem?
Imagine you edit both fields, and actually want to change the title and remove the description entirely, which is valid according to the rules. Then, because you entered a too short title, the validation does not pass, and title will get the new (too short) title as field-value, while the description value will fall back to the value of the $description variable, instead of showing an empty field, which was posted.
It feels like $_POST['description'] = "" is treated like $_POST['description'] = null or is not set - even though the empty field is part of the post.
I'm having some trouble using the Former plugin for Laravel, to handle forms & fields.
The use-case is an "edit"-form for a given model.
Rules:
Expected behaviour:
When loading the edit form, I expect the form to show the values of $title and $description in the fields.
Whenever submitting a the form with invalid field-values, I expect the submitted values to be shown in the fields, instead of the values of $title and $description.
Problem:
This works only when submitting non-empty strings!
When submitting an empty-string, it's like Former handles it like the field-hasn't even been submitted, and therefore uses the value given by $title or $description instead.
I thought Former was able to do this "smart", and take the value($variable) value only if the posted data does not contain the field. But it seems Former is taking the variables value also when the submitted was empty.
Why is this a problem?
Imagine you edit both fields, and actually want to change the title and remove the description entirely, which is valid according to the rules. Then, because you entered a too short title, the validation does not pass, and title will get the new (too short) title as field-value, while the description value will fall back to the value of the $description variable, instead of showing an empty field, which was posted.
It feels like $_POST['description'] = "" is treated like $_POST['description'] = null or is not set - even though the empty field is part of the post.
http://stackoverflow.com/questions/24575011/laravel-former-input-field-posted-with-empty-value-shows-old-original-value-in
The text was updated successfully, but these errors were encountered: