I can't understand whats wrong in my edit:

Original part of code:

 $form['subscribe'] =  array('#type' => 'submit',
      '#value' => t('Subscribe'),
      '#weight' => 20,
    );
    $form['unsubscribe'] = array('#type' => 'submit',
      '#value' => t('Unsubscribe'),
      '#weight' => 30,
    );
  }
  return $form;
}

My edit: (I was trying to add DIV class "rightmove" to this part of code")

 $form['subscribe'] =  '<div class="rightmove">' array('#type' => 'submit',
      '#value' => t('Subscribe'),
      '#weight' => 20,
    );
    $form['unsubscribe'] = array('#type' => 'submit',
      '#value' => t('Unsubscribe'),
      '#weight' => 30,
    );
'</div>'
  }
  return $form;
}

Tell me the right way of adding html tags to the code like this ...

Comments

aj045’s picture

Form elements have two special options you can do this with: $prefix and #suffix
Example:

$form['my_input_field'] = array(
  '#type' => 'textfield',
  '#prefix' => '<div class="sub_cell">',
  '#suffix' => '</div>',
  '#weight' => 20,
);

For more information see: #prefix and #suffix.

Spillerspoiler’s picture

Not working =(((

Edited .module http://decustom.ru/simplenews.module
strings 971-985

aj045’s picture

okay, so whats not working again? Is the button being rendered? Have you looked at the HTML source code on the page that is supposed to have this form? Have you tried clearing Drupal's cache?

Spillerspoiler’s picture

I can't see div class.... Module works, but still there is no div class. Cache is ok....

aj045’s picture

in your module, you are using p tags for the prefix and suffix:
Lines 973-982 (or thereabouts)

$form['subscribe'] =  array('#type' => 'submit',
'#value' => t('Subscribe'),
'#weight' => 20,
'#prefix' => '<p class="rightmove">',
);
$form['unsubscribe'] = array('#type' => 'submit',
'#value' => t('Unsubscribe'),
'#weight' => 30,
'#suffix' => '</p>',);
}
Spillerspoiler’s picture

still no working =((((
I need to : http://i052.radikal.ru/0806/02/b54755916bb2.jpg

and original module http://drupal.org/project/simplenews

Help me please! =)

Spillerspoiler’s picture

nobody can? =(

meric’s picture

If you followed aj045's example things should be fine by now.

can you show us your code? your first post was obviously filled with PHP syntax errors.

I tried this and worked for me.

 $form['subscribe'] =  array(
      '#prefix' => '<div class="rightmove">',
      '#type' => 'submit',
      '#value' => t('Subscribe'), 
      '#weight' => 20,
    );
    $form['unsubscribe'] = array('#type' => 'submit',
      '#value' => t('Unsubscribe'),
      '#weight' => 30,
      '#suffix' => '</div>',
    );
  }
danielb’s picture

You can also use a nested array and then set TREE=true

aj045’s picture

spillerspoiler,
try writing another module at test your piece of code that is breaking-- just that code. if it works in a test module, but not in your main module, you've got a problem some where. That's the breaks with debugging-- it's hard, especially if you gotta do it by hand.

sutharsan’s picture

Use #prefix and #suffix (see: http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/5).

Better than hacking code is to theme the form: http://drupal.org/node/112358

-- Erik

-- Erik