欢迎各位兄弟 发布技术文章
这里的技术是共享的
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 form2) 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 = ''; $output .= ''; $output .= ' '; $output .= ' '.t('CALL').''; $output .= drupal_render($form['call[]']); $output .= ' '; $output .= ' '; $output .= ' '.t('RST').''; $output .= drupal_render($form['rst1[]']); $output .= ' '; $output .= ' '; $output .= ' '.t('NOTE').''; $output .= drupal_render($form['note1[]']); $output .= ' '; $output .= ''; $output .= ''; $output .= ' '.t('UCT').''; $output .= drupal_render($form['uct[]']); $output .= ''; $output .= ''; $output .= ''; $output .= ''.t('QSO').''; $output .= drupal_render($form['qso[]']); $output .= ''; $output .= ''; $output .= ''.t('RST').''; $output .= drupal_render($form['rst2[]']); $output .= ''; $output .= ''; $output .= ''.t('NOTE').''; $output .= drupal_render($form['note2[]']); $output .= ''; $output .= ''; $output .= ''; $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来自 https://www.drupal.org/node/1952912
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
来自 https://www.drupal.org/node/1952912