Reputation: 555
I made a form module (only segment shown) and would like to add some text between questions in the form so I wrote the following, but no text 'text is here' appears.
... $form['name1'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
?><html><p>Text is here </p></html><?
$form['name2'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#collapsible' => TRUE,
'#collapsed' => FALSE, ...
Upvotes: 0
Views: 253
Reputation: 961
One of the reasons why that will not work is because, in your function you are building a form array for Drupal to render not actually outputting the form yourself. so when you break out of the php and output the HTML, it will be output when Drupal runs your function.
What you'll want to do is add a form item of type markup. See the form API
Also, semi-unrelated the #collapsible and #collapsed properties only apply to fieldsets.
So your code would like something like this.
$form['name1'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
);
$form['betweenfields-html'] = array(
'#value' => '<p>Text is here </p>',
);
$form['name2'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
);
Upvotes: 1