I've a child content type with two fields:
- a requied node reference, called "Telecentro" .
- a required date with time (hour and minutes) called "Fecha y Horario". The "to date" option is marked as required too.
This content type is referenced by a nodereference/node_widget field called "field_convocatorias" inthe parent content type.
When I edit a parent node and try to add a child node, filling correctly all fields, it shows me the error:
* warning: Invalid argument supplied for foreach() in [path to project]/sites/default/modules/date/date/date_elements.inc on line 436.
* There are errors in Fecha y Horario:
o Some value must be entered in the To date.
o The To date must be greater than the From date.
I tried to follow the code down to the error and seems like the date/date_elements.inc/date_combo_validate($element, &$form_state) function is using the '#post' data as it were at first level of the form (in the main page form) but the real data is down in a node_widget subform the date module do not knows nothing about: it expect the data in $element[#post][field_convocatorias][0] but it's in $element[#post][field_convocatorias][0][node_widget].
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | node_widget_patch_892152.txt | 5.3 KB | rgrocha |
| #1 | node_widget_patch.txt | 4.82 KB | rgrocha |
Comments
Comment #1
rgrocha commentedI've created a patch to solve this problem.
It also solves some others issues we had in our current project:
- allows multiple values for any child node field (currently tested on dates and text fields)
- support for date_repeat and date_popup_repeat field types
- adds support for other node-processing modules via the hook_nodeapi function (tested with the auto_nodetitle module)
- adds support for the save_edit module. The module now only checks for "submit" Drupal core button.
I've also integrated the path from #791074: Skip does not work if CCK field is required.
I'f using jquery_update you must also apply the patch from #775162: tabledrag.js missing core patches, errors with nested <table>s to support nested tables.
Comment #2
rgrocha commentedA new version of the patch.
Comment #3
Crom commentedThanks for the patch rgrocha. I came across the same date problem as you and then found your patch!
But, when I apply the patch to the current dev (as at 2011-08-19) the parent node saves but the child nodes do not save.
I am going to go back and apply the patch to the current release version and see if that works as it doesn't look like your patch made the current dev version.
Do you have a working version of the module that you could post here?
Thanks,
Crom
Comment #4
Crom commentedI think I've found my issue. In node_widget.form.inc your patch creates a $submit_buttons array. I needed to add 'node_form_submit' to this array to get the child nodes to save. The function is now:
Comment #5
TheDanScott commentedHi rgrotcha / Crom.
Thanks for your efforts on this - I'm experimenting with this patch now to solve an issue I have been having (I had actually resorted to using two separate date fields to get around the validation issues with the "to date" part of a date field).
I'm having a separate issue, which is possibly related to similar issues to the ones you have been fixing here (in that a node with optional fields, other than a single required date field is still seen as "empty" and thus not submitted when the date field is filled in!). I've posted a separate issue at http://drupal.org/node/1342144
I don't suppose either of you would be able to point me in the right direction here?
Cheers
Daniel
Comment #6
TheDanScott commentedIn further testing with this patch, against the current dev release of the node widget module I've found that multi-value file upload / picture upload fields (and possibly others) become broken.
With the patched node widget module active, when uploading files, the surrounding content-multiple table gets reloaded nested within itself.
Sadly I've had to go back to the beta4 release of node widget and put the two separate date fields back :S