I have themed my form, everything works fine but drupal renders
Hello
For remove the div structure form default form rendering you have to override the theme function.
These will help to you : 1) theme_form : http://api.drupal.org/api/drupal/includes!form.inc/function/theme_form/7 for theme the form 2) theme_field: http://api.drupal.org/api/drupal/modules!field!field.module/function/the... for theme the field
Thanks
here are my theming functions:
function add_form_form($form, &$form_state) { $form['call[]'] = array( '#type' => 'textfield', ); $form['rst1[]'] = array( '#type' => 'textfield', '#maxlength' => 4, ); $form['note1[]'] = array( '#type' => 'textfield', ); $form['uct[]'] = array( '#type' => 'textfield', ); $form['qso[]'] = array( '#type' => 'textfield', ); $form['rst2[]'] = array( '#type' => 'textfield', '#maxlength' => 4, ); $form['note2[]'] = array( '#type' => 'textfield', ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', ); $path = drupal_get_path('module', 'add_form'); $form['#attached'] = array( 'css' => array( 'type' => 'file', 'data' => $path . '/css/add_form.css', ), 'js' => array( 'type' => 'file', 'data' => $path . '/js/add_form.js', ), ); return $form; } function add_form_theme(){ return array( 'add_form_form' => array('render element' => 'form'), ); } function add_form_form_field($variables) { foreach($variables['items'] as $delta => $item) { $output .= drupal_render($item); } return $output; } function theme_add_form_form($variables) { $form = $variables['form']; $output = '<div id="log_form_wrap">'; $output .= '<div id="log_call">'; $output .= ' <div class="call">'; $output .= ' <span>'.t('CALL').'</span>'; $output .= drupal_render($form['call[]']); $output .= ' </div>'; $output .= ' <div class="rst1">'; $output .= ' <span>'.t('RST').'</span>'; $output .= drupal_render($form['rst1[]']); $output .= ' </div>'; $output .= ' <div class="note1">'; $output .= ' <span>'.t('NOTE').'</span>'; $output .= drupal_render($form['note1[]']); $output .= ' </div>'; $output .= '</div>'; $output .= '<div class="uct">'; $output .= ' <span>'.t('UCT').'</span>'; $output .= drupal_render($form['uct[]']); $output .= '</div>'; $output .= '<div id="log_qso">'; $output .= '<div class="qso">'; $output .= '<span>'.t('QSO').'</span>'; $output .= drupal_render($form['qso[]']); $output .= '</div>'; $output .= '<div class="rst2">'; $output .= '<span>'.t('RST').'</span>'; $output .= drupal_render($form['rst2[]']); $output .= '</div>'; $output .= '<div class="note2">'; $output .= '<span>'.t('NOTE').'</span>'; $output .= drupal_render($form['note2[]']); $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= drupal_render_children($form); return $output; }
The form is themed but every field has div wraps, how to remove them completely?
IMHO those markups are added for consistent styling rather than recreating new markups. If what you need may be just classes or IDs, you can instead add them via #attributes, e.g.: '#attributes' => array('class' => array('qso')),
'#attributes' => array('class' => array('qso')),
The function relevant to your removal need: http://api.drupal.org/api/drupal/includes!form.inc/function/theme_form_e...
love, light n laughter
Comments
These Will help to you
Hello
For remove the div structure form default form rendering you have to override the theme function.
These will help to you :
1) theme_form : http://api.drupal.org/api/drupal/includes!form.inc/function/theme_form/7 for theme the form
2) theme_field: http://api.drupal.org/api/drupal/modules!field!field.module/function/the... for theme the field
Thanks
here are my theming
here are my theming functions:
The form is themed but every field has div wraps, how to remove them completely?
IMHO those markups are added
IMHO those markups are added for consistent styling rather than recreating new markups.
If what you need may be just classes or IDs, you can instead add them via #attributes, e.g.:
'#attributes' => array('class' => array('qso')),The function relevant to your removal need:
http://api.drupal.org/api/drupal/includes!form.inc/function/theme_form_e...
love, light n laughter