开发者

How to add input field to an element in Drupal hook_elements

开发者 https://www.devze.com 2023-01-20 00:20 出处:网络
I have created a new element with hook_elements.But how do I add a input element like textfield to it?

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),
         ),
      );
}
0

精彩评论

暂无评论...
验证码 换一张
取 消