0

I want to strip all default Drupal form wrappers and have something like below in comment form output

                    <form>
                        <input type="text" name="name" placeholder="Your name">
                        <input type="email" name="email" placeholder="Email">
                        <input type="text" name="website" placeholder="Website">
                        <textarea name="comment_body" placeholder="Comment"></textarea>
                        <input type="submit" value="Send">
                    </form>

I try

    $form['comment_body']['#theme_wrappers'] = array();
    $form['subject']['#theme_wrappers'] = array();
    $form['author']['mail']['#theme_wrappers'] = array();
    $form['author']['name']['#theme_wrappers'] = array();

But not worked for comment_body field, I also use Display Suit I want to know how Can implement comment form like I want without any wrapper.

1 Answer 1

2

To achieve this you need to create one template page for comment-form.tpl.php. For this you need to specify in template.php that uses template page.

<?php
function phptemplate_comment_form($form) {
  return _phptemplate_callback('comment-form', array('form' => $form));
}
?>

and in comment-form.tpl.php you can create your own strcution like

print drupal_render($form['name']);
print drupal_render($form['comment_body']);
print drupal_render($form['subject']);
print drupal_render($form['author']['mail']);
print drupal_render($form['author']['name']);

This works for me with register/login form.

1
  • but when you use drupal_render all div wrapper will be rendered !!!!
    – Yuseferi
    Sep 24, 2015 at 6:38

Your Answer

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

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