Needs review
Project:
Flexifield
Version:
6.x-1.0-alpha5
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
6 Aug 2008 at 11:12 UTC
Updated:
8 Feb 2012 at 15:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
platform8-1 commentedI agree - this module is sick. Nice job.
Comment #2
effulgentsia commentedI agree that needing to delete all the content to delete an item is not the best UI, and that a button/checkbox for doing it would be better.
Comment #3
gagarine commentedI think is a cck issue http://drupal.org/node/196421 for all multiple value. But perhaps they have a easy way to do this...
Comment #4
Anonymous (not verified) commentedIf this is a CCk issue, you should considder ignoring empty flexifields containing mandatory fields. This is related to the issue #390480: Sub-fields of flexifield set as required fail validation on node save., but it's not the same:
In the linked issue, the check fails even for fields that are filled with content.
Here, you should avoid the check for an item, in which all fields are empty, as this is the way, items are deleted in CCK at the moment (again, see #196421: Deleting unwanted multiple values / multiple values delta issues for more information)
Comment #5
stefan81 commentedI would also love to see a "delete" button.
Comment #6
westbywest commentedHere is my kludge to add a delete checkbox to each flexifield on the node edit form, and also to trim away all but one blank flexifield on a node add form. The flexifield CCK field is simply named "field_flex" for legibility.
Comment #7
Silhouette commentedI made some changes to the above code to make it more generic and I used it within flexifield.module. I haven't tested to see if it works with multiple flexifields
Comment #8
ice5nake commentedI think a delete button is needed for this module to hit a stable release.
Comment #9
jpklein commented@ice5nake - totally agree. And I think it's awesome that there's a few of us doing parallel development on this.
I tried implementing the code in #6 & #7 on my installation running alpha5, but I had a problem after hitting the "Add Another Item" button below the flexifield (it was set to 'Unlimited' number of values). Ihe issue is that the AHAH callback bound to the button doesn't reload the entire form and bypasses the form_alter hook which inserts the checkbox.
Instead, I moved the code to create this element to flexifield_default_widget_process() in flexifield.module:
Perhaps because I'm developing on top of alpha5 instead of dev, I didn't see the ['#default_value']['item_id'] form value on which @Silhouette's code seems to depend so I worked around that.
I also cleaned-up the form_alter function - sans the extra-item removal routine - to reduce the amount of code loops, and dynamically add jscript to enhance the UI (see attachment):
The script converts the checkbox into a link and collapses items with a warning message that they will be removed when the form is submitted. Without directly editing tabledrag.js, I had to work around the row objects/elements it creates to display warnings. It seems to be working pretty well, though it doesn't seem to get reloaded if the form gets returned with an error (when the node is missing required fields, for example).
Any ideas/comments greatly encouraged!
Comment #10
jpklein commentedOoops. looks like the last attachment got mangled in translation. Please use this one instead.
Comment #11
jpklein commentedLooks like I answered my own question: instead of binding _flexifield_theme_node_form() to an element in the form, instead just append it to the #after_build attribute of the form itself. So in the flexifield_form_alter() above, make the following change:
hope it helps!
Comment #12
jguffey commented@jpklein Thanks for the hard work! In your comment #9, second block, I'm not sure where you're putting this code so I dropped it into the end of the flexifield module. Made the other changes outlined in comments #10 and #11 and nothing in my flexinode field has changed :( Maybe you can point me in a better direction, or maybe roll you modified alpha 5 for us regular folk!
Thanks a ton for the help, this module solves a lot of my Drupal related gripes.
Comment #13
jguffey commentedohhhh K,
so never mind the problem above, but do note, If you implement these fixes, you will have to recreate your field to get the remove link.
I've attached my version of the module with changes suggested by @jpklein, this variation is based on Alpha 5.
Comment #14
jpklein commentedBump. @effulgentsia, any chance of this being adapted/rolled into a dev release?
Comment #15
Macronomicus commented+ + thanks jguffey!
Works perfectly! I will second that this would be great in the dev at least.
Comment #16
Macronomicus commentedjguffey ... could you provide a patch and/or make this on the dev branch?
The dev has a fix for the Add Another bug that your module using the alpha missing.
Cheers!
Comment #17
boobaaAttached is just #13 in patch format, which should be applied against alpha5.
Comment #18
mparkes commentedAny word on this being applied to the dev branch. The dev branch fixes the add another button not working which is a problem in the alpha.
Comment #19
mparkes commentedSo this doesn't seem to work at all. I'm still seeing entries with empty fields even tho I checked the remove box. What's worse is I changed the number of values to 5. Then I decided to put it back to unlimited. Now I have 5 rows withing the flexifield. I'm using custom price module to calculate the price based on how many entries are entered into the Flexifield. Any idea how to fix this or when it will be fixed?
Comment #20
todd zebert commentedsubscribe
Comment #21
stefan81 commentedhi, would be cool to roll out a new dev release with both issues (add button / remove button) fixed as mentioned at #18
Comment #22
todd zebert commentedI'm not a programmer, but I'm trying to create a simple multi-field like node, with required subfields. I successfully used the patch in http://drupal.org/node/390480 to work-around the invalid "Item Description field is required." errors, but then found I couldn't delete records since all the subfields in one "record" couldn't be empty.
I reapply the patch in the #390480 thread to the 6.x-1.x-dev (2010-Jul-11), and then used the patch file from #17 to create the JS file, and manually adjusted the patch file and applied it against the dev version. Looking at the code (as well as I could) it seemed to layout logically with the DEV version.
Running with the dev version with both patches yielded the "add new item"/"remove item" js buttons, BUT removing a "record" and then Saving produced the same result #390480 was supposed to fix: I now get the "... field is required." error again.
Comment #24
mparkes commentedAny updates?
Comment #25
tomhung commented++ for adding this patch to DEV.
Greg
Comment #26
geek-merlinsub
Comment #27
cmcintosh commentedI needed to get this working so went through and cleared up some of the cluttered code from the above posts. I have noticed that for some reason when you click add more, the delete checkbox is removed from that perticular flexifield's items. This module works on nodes that have multiple flexifields.
Comment #28
ice5nake commented@cmcintosh, would love to see someone committing to this module again.
Comment #29
cmcintosh commentedk so disclaimer. It seems that for some reason when you delete an item it removes the Add More button. Trying to figure out why this happens now. Probably something with ahah_response / how it does its magic.
Comment #30
cmcintosh commentedOk so i was having a bit of issue when I added more items it would remove the items. I figured out a way around this. Around line 626 I added the following:
How ever at this time I am not doing ahah deletion. I still have not worked this part out as of yet and taking a break.
Comment #31
manasiv commented#13 works fine. It does not use AHAH for remove block. +1 to have this in the module's dev release.
Comment #32
cravecode commentedcmcintosh, what version was this written for? I'm using flexifield DEV and nothing happened when i enabled flexifield_delete and recreated by fields.
Thanks!!
Comment #33
ice5nake commentedIt would be great to get this committed to the actual 6.x-1.x-dev. This module is great but needs continued develpment in my opinion.
Comment #34
cmcintosh commentedmy code was made for 6.x-1.0-alpha5, sorry for the response delay.