0

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

1 回答 1

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;
}
于 2013-05-22T09:16:23.287 回答