After exporting some content type (via cck) I've got followed generated code (CCK export):
'referenceable_types' => // #type = checkboxes
array (
'course_date_pl' => true,
0 => 1,
'page' => false,
'story' => false,
'uod_pl' => false,
),
There was no any extra '0 => 1' value, it was extra added by checkboxes_value() function (form.inc) during form_builder()'ing.
It cause many problems with other modules like CCK, Date (i.e. http://drupal.org/node/214115, http://drupal.org/node/128038 #3, http://drupal.org/node/202782)
After importing that code, it cause error:
An illegal choice has been detected. Please contact the site administrator.
Invalid choices are added because of followed loop:
foreach ((array)$form['#default_value'] as $key) {
$value[$key] = 1;
}
If you have #default_value set i.e. checkbox1 = false, checkbox2 = false, checkbox3 = false
this loop will create 3 times the same value: $value[0] = 1; (0 == false)
Patch in attachment.
Comments
Comment #1
kenorb commentedSorry, before was reverse patch.
There is normal patch (in attachment).
Comment #2
kenorb commentedIt can also affect settings of invalid 'referenceable_roles':
Before patch (on export):
After patch:
I don't have any user roles, so after patch seems to working ok.
Comment #3
gddPatch applied and my export works now (in combination with the other patch you submitted.) +1 and thanks a ton, this is really helpful.
Comment #4
gddOn further examination, while the content type is exported and imported without error, the referenceable types on the nodereference are lost on import. To reproduce:
1) Create a new content type "Test".
2) Add a field of nodereference type, choose a content type that can be referenced and save
3) Export this content type
4) Look at the referenceable fields. While it no longer has 0=>1, the referenceable fields are now all false.
5) Import this content type
6) Edit the content type, go to Manage Fields, click configure for this nodereference field
7) No content types are checked
Comment #5
kenorb commented#4
I've tried and works fine.
After exporting I've got selected checkboxes:
So references should be imported.
Do you have also some selection (true) in 'referenceable_types' after exporting in the code?
BTW. Check if you have second patch (#1 section) applied (instead of first, which was invalid).
Comment #6
gddI setup a fresh copy of Drupal 5.7 with CCK 1.6 and applied the patches and everything worked fine, so there must have been a problem with my initial testing environment. This is good to go.
Comment #7
drumm'checkbox1 = false, checkbox2 = false, checkbox3 = false' is the wrong way to set #default_value for checkboxes. It should be an array of form element keys which are checked. So the above example would be an empty array. If #1 and 3 were checked, it would be array('checkbox1', 'checkbox3'). There is an example of this at http://api.drupal.org/api/file/developer/topics/forms_api_reference.html....
Comment #8
demeester_roel commentedsubscribing
Comment #9
amy_cgi commentedCan anyone confirm that when this patch is applied, the checkboxes on the Modules listing (Administer > Site building > Modules) are all unchecked??
Comment #10
amy_cgi commentedActually, for whatever reason, this isn't happening for me anymore.