I have tried drupal_render,drupal_get_form etc for rendering the form,but the form is not being rendered. Is there any error in code or else what else should i add to the code so that it works.
function questionnaire_template_form($form, &$form_state, $question) {
print_r("in template function");
$form_build = unserialize($question->criteria_data);
foreach ($form_build as $key => $value) {
$options = ($form_build[$key]['1']);
$list = explode("\n", $options);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
foreach ($list as $key => $value) {
$new = explode('|',$value);
$new_key = reset($new);
$new_value = end($new);
$new_list = array($new_key => $new_value);
dsm($new_list);
}
dsm('next');
$fb = explode("_",$key);
$type =reset($fb);
if($type == 'radio') {
if($form_build[$key]['0']) {
$form['radio_form'] = array(
'#type' => 'radios',
'#options' => $list,
);
}
}
elseif($type == 'checkbox') {
if($form_build[$key]['0']) {
$form['checkbox_form'] = array(
'#type' => 'checkboxes',
'#options' => $list,
);
}
}
elseif($type == 'selectlist') {
if($form_build[$key]['0']) {
$form['selectlist_form'] = array(
'#type' => 'select',
'#options' => $list,
);
}
}
}
return $form;
}
Above code is my form.
<div>
<?php
//print_r($variables['entity']->qid);?></br><?php
print_r($variables['entity']->title);?></br><?php
print_r($variables['entity']->text);?></br><?php
?></br><?php
?></br><?php
if($variables['entity']->criteria) {
?><br/><?php
$form_template = drupal_get_form('questionnaire_template_form' , $variables['entity']);
print(drupal_render($form_template));
}
?></br><?php
print_r(l( t("Yes"), 'questionnaire/' . $variables['entity']->yes_quid));?></br><?php
print_r(l( t("No"), 'questionnaire/' . $variables['entity']->no_quid));?></br><?php
?>
</div>
And this is the template where I am rendering the form. I am getting the form if I dsm the form