用包装器创建drupal表单

时间:2013-05-22 07:07:01

标签: forms drupal-6

我已经以编程方式在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;
}

1 个答案:

答案 0 :(得分:2)

以下是答案

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;
}