Active
Project:
Multifield
Version:
7.x-1.0-alpha1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Apr 2015 at 13:33 UTC
Updated:
15 Aug 2016 at 12:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Tilo Schumann commentedSame problem here. I cannot remove last (id est "first") item.
When I add a new (empty) item, place it first and delete the old one I get:
Error: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fid' cannot be null: ...
Tested versions: 7.x-1.0-alpha1 and 7.x-1.x-dev
Update:
Meanwhile I see, you have to empty all fields of the "last" item by yourself.
My sites runs into an error, when you remove a file, but forget to reset a radio-Button. I have to prevent this by a validation-handler.
Perhaps you can solve that problem in one of the next updates.
Thank you
Comment #2
kyle.veldhuizen commentedI am also having this issue.
Comment #3
chrisrockwell commentedI'm able to reproduce this using alpha3 and dev in my current project. I also did a clean install on simplytest.me and got the same result. I'm looking through the tests now and will try to create one that reproduces this.
Comment #4
chrisrockwell commentedI'm not sure if this helps but...If you have, for example, a select list in your multifield do the following:
1. Edit the entity
2. Remove all but one of the multiple value multifields.
3. Change the value of the select list in the remaining field
4. Click "Remove"
This will result in the select list resetting itself to the original value, instead of deleting the element. I've just found time to work on this so I'm digging in now.
Comment #5
chrisrockwell commentedI have more information, unfortunately it doesn't get me any closer to solving it.
Another issue with the remove button is when the following happens:
Within multifield.field.inc the comments indicate the code was copied from field_collection.module. However, the code in question has since been patched due to https://www.drupal.org/node/1675522. The committed patch is: http://cgit.drupalcode.org/field_collection/commit/?id=d797efa
Comment #6
chrisrockwell commentedI have also tested this behavior with https://www.drupal.org/project/multiple_fields_remove_button and it's the same thing. Not surprisingly, the code is almost the exact same as well.
For now I need to move on. In the hopes that it will help someone either A) get closer to fixing the issue or B) improve the experience for users until it can be fixed, I'm attaching a patch that I am using for the time being. I would recommend replacing $element['actions']['remove_button']['#submit'] with a callback to your modified function.
First, it just adds #states to hide the remove button if an element doesn't have a selection (specific to my use case but it can easily be adapted). Second, it resets the value of the element (I'm only dealing with one subfield right now so I'll have to adjust it as more are added) if a user tried to remove it.
Sorry this isn't much help :(
Comment #7
elijah lynnSomewhat of the same issue but maybe worth making another for is that if you don't choose unlimited and choose a fixed amount. You have to remove or reset all the fields manually if you want to 'remove' one.
Comment #8
chrisrockwell commentedHi Elijah, I wasn't able to reproduce that on a simplytest.me install using 7.x-1.0-alpha4. I created a field with cardinality of 3 and then went back and edited the node 3 times, removing one entry at a time.
I did have to clear out the field to remove it, which isn't user friendly but isn't an issue isolated to this module. I do think it would be a UX improvement to have "Add Another" and "Remove" to add fields as needed, up to the set limit, instead of just having it on unlimited value fields.
This issue came up in a demo today so, maybe, I'll be given some time to look further into this :).
Comment #9
elijah lynnYes, that is what I was referring to. It would be nice to have a 'reset' button in that case.
Comment #10
dave reidYeah, it's a problem not unique to multifield itself, but to all field widgets.
Comment #11
elijah lynn@Dave Reid - Thanks for clarifying that. I did go ahead and make an issue for a remove button in Multifield, any suggestions are appreciated as I have to get this working.
#2751755: Create a 'remove/reset' button when not using 'unlimited' value for field instance
Comment #12
elijah lynnI have been investigating #2782747: Removing Multifield followed by 'add another item' adds back the removed item and there are a few issues for Field Collection linked to that one. When those patches are refactored into Multifield it appears this issue may also be resolved. As the latest Field Collection removes/resets the last entry correctly.