Posted by pkej on March 4, 2009 at 4:48am
| Project: | Flexifield |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
In alpha 1 I could set the flexifield to required and add data in it, and it would save.
After upgrading to alpha2 the required fields will never save, the node can not be edited.
Comments
#1
Subscribing. I think this problem is quite critical, since requirement validation is important for correct content submission (unless you rely on moderator to check every piece of content).
#2
#3
#4
subscribing. Having the same problem here.
#5
As I mentioned in #291864: Make it easier to delete an item, the validation must not be done for a set in which all fields are empty, as this sets are ment to be ignored by cck.
#6
Exactly, ignoring an item with all fields empty would solve all of the issues I have with Fiexifield. Any estimation on when this could be done? Or any hint as to how one can fix this?
#7
It is quite tricky. When flexifield renders widgets for every child field, they set "required" property depending on child field item delta and field "required" setting. This is done so optional rows in multiple values field don't fail validation, and there is only row 0 required. Now in flexifield this leads to the bug when in every flexifield row child field have first delta starting from 0 so if child field is required every 1st row in every flexifield row becomes required.
I tried to overcome this bug: I inserted fake "required" field setting so on flexifield row 0 child fields can be required but on row 1 and more they can't.
This seem to only partially fix this problem cause it all still fails validation. Probably we need to insert more fakes to make all field validations pass.
My half-working patch is attached, I hope you guys will come with new ideas for this. I think there's much more needs to be done, as it's only widget validation and some fields may have additional validation at field level.
We need someone that has good knowledge of FAPI and CCK to fix this probably..
#8
+1 I am getting this as well.
I solved it now by removing the required option on the sub node fields, and just informing users that they must fill it out.
#9
subscribing. this is indeed a critical issue.
#10
Subscribing
#11
Subscribing. This issue really needs to be addressed.
#12
We ran in this issue as well and we could not afford removing the required fields from the sub-fields.
To correct this my colleague moritzz (http://drupal.org/user/132136) created the enclosed patch that I submit on his behalf.
Basically it works this way: it checks if a subform element is empty and if so the element and all its children get the required flag cleared so further validation passes silently.
This patch is not perfect and will not work with all the types of sub-fields. For example we know there are problems with the date fields because of the way they check if they are empty. Since we don't use date fields in our project we didn't take the time to dig into this further. But with some code hacking it must be possible to use date fields as well.
We have also to mention that for sub-fields of type file field, this patch will only work if you enabled the "flexifield filefield integration" module.
#13
In addition to the patch created by moritzz you may find usefull this quick modification of the flexifield module that make the workaround work for nodereference sub-fields.
// Strangely enough, when a nodereference field is used into a flexifield,
// the value is not stored the same way as when used outside a flexifield.
//
// Normaly the value is stored this way:
//
// $aChildField = array('nid' => THE VALUE)
//
// But in a flexifield, the value is stored with an additionnal array level, like this:
//
// $aChildField = array('nid' => array('nid' => THE VALUE))
//
// Because of this, the normal routine will always consider the nodereference field is NOT empty.
//
// The following code corrects this problem.
#14
subscribing
#15
#16
I encountered this also, has this problem been around for 1½ years already? I think this is quite critical issue and limits the usage of flexifield significally
#17
It is clear that Flexifield was abandoned long time ago.
#18
subscribe.
This is annoying as neither Flexifield nor CCK3 Multigroup are ready for prime time yet, for such a (it seems to me) basic need.
Of course, as only a cut&paste programmer, I can't do anything about it, and probably shouldn't complain.
#19
Thanks for the support & patch dan_liip & moritzz. It worked for the simple implementation I have.
#20
Perhaps I spoke to soon. I'm using Alpha5 and with the patch above.
There doesn't seem to be any way to delete a "record" since the source node shows at least one field as required.
Or am I missing something?
#21
See my comments on the related "record" delete Flexifield thread, http://drupal.org/node/291864#comment-3650452
#22
Rerolled #12 patch so it should (hopefully) apply via drush make.