Alter the comment form I have the following code to alter the way comment form is displayed. After the bellow code everything is displayed as i want to but it does not add the comments.

 global $user;
     if ($user-&gt;uid) {
       $form['author']['_author'] = array
     (
        '#tittle' =&gt; 'Name',
        '#attributes' =&gt; array('id'=&gt;array('name')),
        '#prefix' =&gt;'&lt;ul&gt; &lt;li class="name_field_c"&gt;&lt;label for="name"&gt;Name&lt;/label&gt;'.$form['author']['_author']['#markup'],
        '#suffix' =&gt; '&lt;/li&gt;'
     );   
     }
     else {
     $form['author']['name'] = array
     (
        '#type' =&gt;'textfield',
        '#attributes' =&gt; array('id'=&gt;array('name')),
        '#prefix' =&gt;'&lt;ul&gt; &lt;li class="name_field_c"&gt;&lt;label for="name"&gt;Name&lt;/label&gt;',
        '#suffix' =&gt; '&lt;/li&gt;'
     );  
     }

     $form['author']['mail'] = array(
        '#type' =&gt;'textfield',
        '#attributes' =&gt; array('id'=&gt;array('email')),
        '#prefix' =&gt; '&lt;li class="email_field_c"&gt;&lt;label for="email"&gt;Email (optional)&lt;/label&gt;',
        '#suffix' =&gt;'&lt;/li&gt;',
        '#required'=&gt;TRUE,
        '#weight' =&gt; 2
     );

    $form['comment_body'] = array
     (
        '#type' =&gt; 'textarea',
        '#attributes' =&gt; array('id'=&gt;array('comment')),
        '#prefix' =&gt; '&lt;li class="comment_field_c"&gt;&lt;label for="comment"&gt;Comment&lt;/label&gt;',
        '#suffix' =&gt; '&lt;/li&gt;',
        '#weight' =&gt; 4,
        '#resizable' =&gt; FALSE
     );


     $form['author']['homepage']['#access'] = FALSE;
     $form['subject']['#access'] = FALSE;


     $form['captcha']['#prefix'] = '&lt;li&gt;&lt;div class="captcha"&gt;';
     $form['captcha']['#suffix'] = '&lt;/div&gt;';
     $form['actions']['submit'] = array (
        '#prefix' =&gt; '&lt;button type="submit"&gt;',
        '#suffix' =&gt; '&lt;/button&gt;&lt;/li&gt;&lt;/ul&gt;',
        '#markup' =&gt; '&lt;span&gt;' . t('Say your piece') . '&lt;/span&gt;'
     );

    $form['#action'] = $_SERVER['REQUEST_URI'];


To submit the form i have to press twice on the submit button ( how can i solve it ? ) and after i submit the form again i get the following errors and i cannot figure it out how to solve them:

Warning: array_values() [function.array-values]: The argument should be an array in _field_filter_items() (line 513 of /home/mcristi/public_html/jhub/modules/field/field.module).
Warning: Invalid argument supplied for foreach() in text_field_validate() (line 119 of /home/mcristi/public_html/jhub/modules/field/modules/text/text.module).
Notice: Undefined index: homepage in comment_form_validate() (line 2155 of /home/mcristi/public_html/jhub/modules/comment/comment.module).


This thing causes the problem that the form is not submitted/saved :

 $form['actions']['submit'] = array (
        '#prefix' =&gt; '&lt;button type="submit"&gt;',
        '#suffix' =&gt; '&lt;/button&gt;&lt;/li&gt;&lt;/ul&gt;',
        '#markup' =&gt; '&lt;span&gt;' . t('Say your piece') . '&lt;/span&gt;'
     );

    $form['#action'] = $_SERVER['REQUEST_URI'];


Is there any possibility to save the comment on the node page ? ( to not be redirected to /comment/reply/$nid)
You're overwriting the form elements that are already there, some of which are fields and so need to have their array structured very specifically (Why is hook_form_alter so messy in d7? has some background for that).

You can alter existing elements in the form without overwriting the whole thing like so:

$form['comment_body']['#prefix'] = '&lt;li class="comment_field_c"&gt;&lt;label for="comment"&gt;Comment&lt;/label&gt;';
$form['comment_body']['#suffix'] = '&lt;/li&gt;',