Steps to reproduce :
(1 to 5 are just there to outline the 'expected' behaviour)
1 - Define a text field - mark it multiple / NOT required
2 - Create a node with 3 values 'foo', 'bar' and 'baz' for the field
3 - Submit
4 - Edit the node, empty the first value 'foo'
5 - Submit : everything OK, the field has the values 'bar' and 'baz', and if you edit the node, you get 'bar' and 'baz' in the first and second textfields (values have shifted)
6 - Now set your field to REQUIRED
7 - Edit the node, empty the first value 'bar'
8 - Submit : you get a 'field is required' error on the first (empty) textfield, yet the field itself should not be considered empty, since you have the 'baz' value in the second textfield
This is content.module stuff - you get the behaviour with number, or noderef with autocomplete fields.
Comment | File | Size | Author |
---|---|---|---|
#13 | 93447.gif | 4.16 KB | TravisCarden |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedYou definitely have found a bug that needs to be swatted. The only thing I would question is the last item where you say you should not get an 'field is required' error if one value is empty. I would interpret required for a multiple value field as requiring that every one be filled out, but maybe that's not the right way to look at it. Sounds like something that needs to be hashed out -- what does 'required' mean for a multiple value field?
Comment #2
yched CreditAttribution: yched commentedWell, if we had advanced 'multiple' definitions like 'between 3 and 5 values', 'exactly 2', or 'more than 1', it would be different. Then every value could have different semantics.
For the time being, where 'multiple' just means 'possibly several' (and then necessarily 'possibly several of the same thing), i can't think of any other meaning for 'required' than 'not empty'.
'required' can't mean 'every value must be filled out', since 'every' doesn't mean anything...
Let me put it this way :
Say you have a required multiple field
You set its values to 'a ', 'b' and 'c'
Currently, you can edit the node and remove 'c' (last one), but not 'a' or 'b'.
In order to do that, you have to manually shift all the values in the form in order to leave the empty textfields at the end.
Sounds strange, no ?
Comment #3
Egon Bianchet CreditAttribution: Egon Bianchet commentedSubscribing ...
Comment #4
KarenS CreditAttribution: KarenS commentedI hadn't thought too much before about blank fields in the middle, but another question is how do you know if blank fields at the end are fields that are not wanted or not. My original thought had been that you just throw out all blank fields, but if for some reason position is important (not sure why it would be yet, especially since there are no labels or other identifiers for these fields) and there must be blank fields in the middle, then that won't work.
To really solve this issue I think we need to also address the question of how you identify how many multiples you want so we know when to stop adding fields. I think you can make a case that there are times when 'required' should mean that every field is to be filled out, which as you say means we must know how many fields are required, and other times when it might mean only that at least one field needs to be filled out.
I'm inclined to think we must address these two issues together -- a way to indicate how many multiples are needed and a decision about what 'required' means for multiple fields.
Comment #5
yched CreditAttribution: yched commentedKind of related bug : http://drupal.org/node/93671
Seems like we do have to be more specific about the definition, 'philosophy' and expected behaviour for multiple fields :-)
Comment #6
yched CreditAttribution: yched commentedfixed in D6
Comment #7
yched CreditAttribution: yched commentedActually, not fixed :-)
content_set_empty() should take care of stacking non empty deltas at the begining of the $items array.
Comment #9
markus_petrux CreditAttribution: markus_petrux commentedClosing the issue until the spammer comment above is removed.
Comment #10
GuyPaddock CreditAttribution: GuyPaddock commentedI'm still seeing this behavior with 6.x-2.6, so I'm re-opening it.
We have a required, multiple-value text field set to take an "Unlimited" number of entries. When entries are removed from the middle of the field (so {"abc", "def", "ghi"} becomes {"abc", "ghi"}) or from the end (so {"abc", "def", "ghi"} becomes {"abc", "def"}), no validation error occurs. However, when the first entry is removed (so {"abc", "def", "ghi"} becomes {"def", "ghi"}), we get "field is required".
Regardless of what the meaning of "required" should be, if it doesn't raise errors for removing other entries, the first field shouldn't be special.
Comment #11
catofcheshir CreditAttribution: catofcheshir commentedI'm stuck with this with date field (required, muptiple values). Only first entry mark with a red '*' , and i can't remove this entry regardless of presence of any more entries.
Comment #12
zazakis CreditAttribution: zazakis commentedTo really solve this issue I think we need to also address the question of how you identify how many multiples you want so we know when to stop adding fields. I think you can make a case that there are times when 'required' should mean that every field is to be filled out, which as you say means we must know how many fields are required, and other times when it might mean only that at least one field needs to be filled out.video izle I'm inclined to think we must address these two issues together -- a way to indicate how many multiples are needed and a decision about what 'required' means for multiple fields
Comment #13
TravisCarden CreditAttribution: TravisCarden commentedIndeed. I think there is inherent ambiguity in asking a user to delete the content of a field value to signify that they want to remove the whole position at that delta. I don't think the action corresponds to the function. Much more logical, in my mind, would be to delete the value at a position when what you want is a position with an empty value, and create a separate UI element for the (really distinct) function of deleting the whole position from the list—for example, a delete link or button next to each position, as depicted in the attachment. Not only would this eliminate ambiguity, it would make the act of deleting a field value both more "findable" and more "intuitive". (What is the new user left to think when there is a button specifically to "Add another item" but no corresponding button to remove one. It would not be unreasonable to assume, at first glance, that you can add but not remove.)
I also agree that the concept of "required" needs to be more flexible. I should think that the following two options would cover most use cases:
Comment #14
TravisCarden CreditAttribution: TravisCarden commentedI submitted my suggestion as a separate issue at #1120162: Add "delete" links to multivalue field values because I think it has broader implications than simply this issue (even though it would contribute to the solution of this, as well).
Comment #15
TravisCarden CreditAttribution: TravisCarden commentedThis is still a problem in fields in core.
Comment #22
merauluka CreditAttribution: merauluka at Mediacurrent commentedComment #23
merauluka CreditAttribution: merauluka at Mediacurrent commentedWe are seeing this issue on fields in Drupal 8 also. When a user attempts to remove the first item in a required, multi-value field, the HTML validation fails since the first input in the list has the
required="required"
attribute set in HTML.Removing the text from this field is not sufficient to resolve the issue. Nor is reordering the fields. The only workaround we've found so far is to literally add something into the first field and then reorder it as needed. That satisfies the HTML validation and allows Drupal to perform it's form processing.
I think a better solution, and one I've heard requested by a lot of users, is a "remove" button. This is discussed for core here:
https://www.drupal.org/project/drupal/issues/1038316
But there is also a module that appears to add a remove button. The Ajax involved should resolve this issue. Perhaps its logic can be introduced into core?
https://www.drupal.org/project/multiple_fields_remove_button
Comment #26
quietone CreditAttribution: quietone as a volunteer commentedThis is the same problem that is being solved in #1038316: Allow for deletion of a single value of a multiple value field
While this is the earlier issue the other one has patches and more discussion. Closing this as a duplicate and moving credit.
Comment #27
brad.bulger CreditAttribution: brad.bulger commentedThe issue that this is marked as a duplicate of is not really this same problem. It is about a UI widget to let users remove items from a multiple value field. I added a new issue #3344082: Improve required validation of multiple value fields that is about improving 'required' validation of multiple value fields, to consider the field as a whole instead of only delta 0 in whatever position it might be.