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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timos’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
timos’s picture

Assigned: Unassigned » timos
Status: Active » Needs review
FileSize
694 bytes

Here the patch to the task described above

Status: Needs review » Needs work
timos’s picture

Hi

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.

timos’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
timos’s picture

Assigned: Unassigned » timos

#2: 1365412-use-array-filter-to-populate-default-value-for-referenceable-types-2.patch works and passed the test.
Now, it needs review.
Cheers

timos’s picture

Assigned: timos » Unassigned
Status: Needs work » Needs review