Hi
I found out that the $form['referenceable_types]['#default_value'] array in the node_reference.module file (l82) is populated from the $field['settings']['referenceable_types'] array when i applied a patch to solve an core issue about checkboxes default value is ignored by forms system during processing of AJAX request (http://drupal.org/node/1100170).
After i applied this patch, the behavior of the node reference field edit form was very strange (see http://drupal.org/node/1100170#comment-5343080).
The no use of the array_filter() function has for result that $form['referenceable_types]['#default_value'] array has somes keys with a value set to '0'.
I think it should be better if the array_filter was used, like in the user_reference module.
I'll try to do a patch for that, but i put here the code i'm thinking to do :
replace :
<?php
'#default_value' => $settings['referenceable_types'],
?>
by
<?php
'#default_value' => is_array($settings['referenceable_types'])
? array_filter($settings['referenceable_types'])
: array(),
?>
there is any reason to not do that ?
Cheers
Comment | File | Size | Author |
---|---|---|---|
#2 | 1365412-use-array-filter-to-populate-default-value-for-referenceable-types-2.patch | 694 bytes | timos |
Comments
Comment #1
timos CreditAttribution: timos commentedComment #2
timos CreditAttribution: timos commentedHere the patch to the task described above
Comment #4
timos CreditAttribution: timos commentedHi
what can cause a drupal installation failure ?
I tested my patch on a dev site and i ran a reference test with simpletest, and i encountered no problem.
I made the patch following http://drupal.org/node/707484 workflow from a references module repository as root for my git project.
Comment #5
timos CreditAttribution: timos commented#2: 1365412-use-array-filter-to-populate-default-value-for-referenceable-types-2.patch queued for re-testing.
Comment #7
timos CreditAttribution: timos commented#2: 1365412-use-array-filter-to-populate-default-value-for-referenceable-types-2.patch works and passed the test.
Now, it needs review.
Cheers
Comment #8
timos CreditAttribution: timos commented