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
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
If you add an item, get its inputs into an invalid state (e.g., by leaving a required field blank), and then remove the item, client_side_validations (and probably other client-side validation solutions) will still flag the now-hidden fields as invalid, but the user has no way to "correct" them.
I can work around this from the validation side, but I'm thinking, is there any reason to keep the .fields around once an element is removed? What if we just remove it, or replace it with the hidden 'destroy' input if there is one?
The text was updated successfully, but these errors were encountered:
if we remove .fields the _destroy input will be removed and no destruction will happen.
I don't know replacing with _destroy is good or not, but simply setting the hidden filed values to empty may work,
just after $(this).closest('.fields').hide(); add this: $(this).closest('.fields').find(":input:hidden").each(function() { $(this).val(""); });
It seems like that has the reverse of the desired effect: It nullifies the _destroy input (so the item won't be deleted), but leaves the other fields intact (so client_side_validations will flag invalid input, even though it's supposed to be deleted).
I made a mistake here, and you are right. I don't think there is a reason by not to remove that elements, because there is no way to access fields after hiding them (at least for now). And for this problem it's enough (and also more easy) to only remove the inputs from form and hide the rest, by putting:
If you add an item, get its inputs into an invalid state (e.g., by leaving a required field blank), and then remove the item,
client_side_validations
(and probably other client-side validation solutions) will still flag the now-hidden fields as invalid, but the user has no way to "correct" them.I can work around this from the validation side, but I'm thinking, is there any reason to keep the
.fields
around once an element is removed? What if we just remove it, or replace it with the hidden 'destroy' input if there is one?The text was updated successfully, but these errors were encountered: