I have created a new element with hook_elements.But how do I add a input element like textfield to it?
I wrote the following code,textbox is shown on form but when I print form_state values in form's submit function there is not any value for that.Is process function the right place to add the input field?
function test_elements() {
return array(
'test_field开发者_JAVA技巧' => array(
'#input' => TRUE,
'#process' => array('test_field_process'),
)
);
}
function theme_test_field($element) {
$output = $element['#title'];
$output .= drupal_render($element['#txtbox']);
return $output;
}
function test_field_process($element, $edit, &$form_state, $complete_form) {
$element['#txtbox'] = array(
'#type' => 'textfield',
'#title' => 'Enter value'
);
return $element;
}
Do you implement hook_theme to describe test_field?
like
function test_theme() {
return array(
'test_field' => array(
'arguments' => array('element' => NULL),
),
);
}
精彩评论