altering form with hook_form_FORM_ID_Alter function dental_form_simplenews_block_form_2_alter(&amp;$form, &amp;$form_state, $form_id)
{
    global $user;
    $form = array();
    $form['#attributes'] = array('class' =&gt; array('newsletter'));
    /*$form['subscribe'] = array(
        '#type' =&gt; 'fieldset', 
        '#title' =&gt; '', 
        '#weight' =&gt; 5, 
        '#collapsible' =&gt; TRUE
    );*/
    if ($user-&gt;uid) {

    }
    else {
        $form['mail'] = array(
            '#type' =&gt; 'textfield',
            '#title' =&gt; t('Email'),
            '#size' =&gt; 20,
            '#maxlength' =&gt; 128,
            '#required' =&gt; TRUE,
            '#attributes' =&gt; array('class' =&gt; array('text_ip')),
        );
        $submit_text = t('Subscribe');
        $form['action'] = array(
          '#type' =&gt; 'value',
          '#value' =&gt; 'subscribe',
          '#attributes' =&gt; array('class' =&gt; 'submit'),
        );
    }

    return $form;

}


Above is the code i am using to alter form produced by simplenews plugin. But i am getting various error messages.

Notice: Undefined index: #parents in form_builder() (line 1713 of /home/sjd/www/example.com/includes/form.inc).
Warning: implode() [function.implode]: Invalid arguments passed in form_builder() (line 1713 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: #tree in form_builder() (line 1743 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: #array_parents in form_builder() (line 1766 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: process_input in _form_builder_handle_input_element() (line 1904 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: complete form in form_builder() (line 1723 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: #tree in form_builder() (line 1743 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: #array_parents in form_builder() (line 1766 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: process_input in _form_builder_handle_input_element() (line 1904 of /home/sjd/www/example.com/includes/form.inc).
Notice: Undefined index: process_input in drupal_process_form() (line 817 of /home/sjd/www/example.com/includes/form.inc).


Can anybody tell me where i am going wrong.
You shouldn't reset the form completely by doing $form = array();, since you will delete some of the stuff Drupal expects to be there.

You should instead do something like this:

function dental_form_simplenews_block_form_2_alter(&amp;$form, &amp;$form_state)
{
    global $user;
    // Remove what you don't want..
    unset($form['fields']);
    // Add what you do want..
    $form['#attributes'] = array('class' =&gt; array('newsletter'));
   ...
}