1

I need to put some custom html tags and code inside the form elements am creating using form api . I defined a fieldset and need to come the html under this fieldset , code sample :

  $general_wb_vars = array(
        'wb_debug'=>array('type'=>'select','values'=>'ERR,OFF','default_value'=>'OFF','label'=>'Debug','description'=>''),
        'wb_cache'=>array('type'=>'radio','values'=>'Yes,No','default_value'=>'No','label'=>'Cache','description'=>''),
        'wb_ip'=>array('type'=>'textfield','values'=>'','default_value'=>'192.168.1.1','label'=>'IP','description'=>'')
        );
        $numofrepeat = 4;
        if($form_id=='my-form-id'){
                $form['fieldsetm'] = array('#type' => 'fieldset',
                                         '#title' => t('Weblogic configurations'),
                                         '#weight' => 10,
                                );

                for($i=1;$i<=$numofrepeat;$i++){
                foreach($general_wb_vars as $id => $setts){
                   $form['fieldsetm']['field_p_'.$id.'['.$i.'][value]'] = array('#type' => $setts['type'],
                                        '#title' => t($setts['label']),
                                        '#default_value' => $setts['default_value'],
                                        '#description' => t($setts['description']),
                                        '#attributes' => array('id'=>$id.$i),

                                  );
                                if($setts['type']=='select'){
                                        $form['fieldsetm']['field_p_'.$id.'['.$i.'][value]']['#options'] = explode(',',$setts['values']);                                      }
                                if($setts['type']=='radio')
                                        $form['filedsetm']['field_p_'.$id.'['.$i.'][value]']['#values'] = explode(',',$setts['values']);
                                        $form['fieldsetm']['some_markup'] = array(
                                           '#type' => 'item',
                                           '#markup' => '---------------------------------------------------------------------',
                                         );
                                }                               
                }

1 Answer 1

1

You're looking at Drupal 7 form api reference perhaps. For drupal 6 according to the form api you just need to put your HTML string in #value as the default D6 #type is markup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.