Store "Form Multicrud" module array in a CCK Computed field
Last updated on
30 April 2025
Hello,
I love the Form Multicrud module, here it is:
http://drupal.org/project/multicrud
I wanted to store this as a CCK field with my content type and collect data from users with it. It is a perfect solution for prompting and showing Tabular data.
For Computed Code:
(given your form element name is multicrud
$node_field[0]['value'] = serialize($node->multicrud);
In Display field
$rows = unserialize($node_field_item['value']);
$header = array(mycolumn1,mycolumn2,mycolumn3,mycolumn4);
$display = theme_table($header,$rows["items"]);
In your hook_form_alter (so that you display the form on node edit page:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if($form_id == "story_node_form")
{
$stored_multicrud = unserialize($form['#node']->field_my_computed_field_name['0']['value']);
//drupal_set_message(dpr(,true));
$form['multicrud'] = array(
'#title' => 'Accounts',
'#type' => 'multicrud',
'#weight' => 100,
'#multicrud_elements' => array(
// overwrite these!
'mycolumn1' => array(
'#title' => 'Mycolumn1',
'#type' => 'textfield',
'#size' => 30,
),
'mycolumn2' => array(
'#title' => 'Mycolumn2',
'#type' => 'textfield',
'#size' => 30,
),
'mycolumn3' => array(
'#title' => 'Mycolumn3',
'#type' => 'textfield',
'#size' => 30,
),
'mycolumn4' => array(
'#title' => 'Mycolumn4',
'#type' => 'textfield',
'#size' => 30,
),
),
'#default_value' => $stored_multicrud["items"]
);
}
}
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion