使用包装器创建drupal表单



我以编程方式在drupal中创建了一个表单。我如何用div包装表单的每个元素。下面是我的示例代码

    function emailusers_compose_form($context, $account) {
    $form['to'] = array(
    '#type' => 'value',
    '#value' => $account,
   );
$form['message']['subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#size' => 50,
'#maxlengh' => 255,
'#description' => t('The subject of the email message.'),
);

$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send Mail'),
);
return $form;
}

答案如下

function emailusers_compose_form($context, $account) {
  $form['to'] = array(
    '#type' => 'value',
    '#value' => $account,
  );
  $form['message']['subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#size' => 50,
    '#maxlengh' => 255,
    '#description' => t('The subject of the email message.'),
    '#prefix' => '<div id="elementid">',
    '#suffix' => '</div>'
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send Mail'),
  );
  return $form;
}

最新更新