I've got a validation form (id="mymodule-myct-verify-form"
) that retrieves data from temp_node
to populate it's hidden fields. On submit, the form sends its data to /node/add/myct. (currently via $form['#method' = 'get';
, which I'm planning on changing to 'post') What I want to do is this: in mymodule_hook_form_alter
, get the data from $_REQUEST
(later $_POST
) and use that to set the default values of my CCK fields. Currently, jQuery is the approach I'm going for, being unable to get mymodule_form_alter()
and mymodule_after_build_convert()
to work. Here's what I've got:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'].'' == "myct") {
// if converting, set default values through an after_build function
if (isset($_REQUEST['conv']) && (strip_tags($_REQUEST['conv']) == 'app') &&
isset($_REQUEST['taid']) && (intval($_REQUEST['taid']) > 0)
&& ($form['type']['#value'] . '_node_form' == $form_id &&
(strpos($form['#action'], '/node/add/myct') !== FALSE))
) { // on the /node/add/myct/?conv=app&taid=1 page, this is true
$form['#after_build'][] = 'mymodule_after_build_convert';
}
}
}
function mymodule_after_build_convert ($form, &$form_state) {
//TODO: Set default values for CCK fields
/*dsm($form);
dsm($form_state);
dsm($_REQUEST);*/
// set receiving date and time
dsm($form['#field_info']['field_status_10']); // date popup
$form['#field_info']['field_status_10']['widget']['default_value'] = time(); //date("j F, Y - H:i");
dsm($form['#field_info']['field_status_10']);
// set deal type (select list)
$form['#field_info']['field_deal_type']['widget']['default_value'][0]['value'] = intval($_REQUEST['ta_type']);
return $form;
}
Why is my date_popup field empty instead of containing today's date? Why does the select list not change?