Prepopulate flexifields
chirale - October 4, 2008 - 21:34
| Project: | Flexifield |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Prepopulate module provides an handy way to populate CCK fields.
Flexifield seems somehow incompatible with prepopulate since query like:
edit[field_my_flexifield][0][value][my_cck_field_into_a_flexifield][0][value]=myvalue
are ineffective. Any idea to implement it on Flexifield CCK fields? I found it very useful to pass node reference nid to a "children" page from its parent, e.g.
edit[field_my_flexifield][0][value][field_mynodereference][0][nid]=12

#1
I only found this way to populate flexifields.
On flexifield node (node used by flexifield to generate single fields rows) on Default value > PHP code I put:
<?phpif(isset($_GET['edit']['field_mynodereference']['0']['nid']) && is_numeric($_GET['edit']['field_mynodereference']['0']['nid'])) {
return array(
0 => array('nid' => $_GET['edit']['field_mynodereference']['0']['nid']),
);
}
else return array(
0 => array('nid' => NULL),
);
?>
And flexifield now display the default value for ['field_mynodereference']['0']['nid'] correctly.
Since this should be done for each field to be prepopulated, the Prepopulate way is cleaner.