Search code examples
phpdrupaldrupal-theming

Drupal 7, how to span html/markup in a submit element?


Ive created the a button

$form['submit'] = array(
 '#type' => 'submit',
 '#value' => 'verify',
 '#tree' => TRUE,
);

And I have added some markup code

 $form['submit']['verify'] array(
 '#markup' => 'example text',
 );

The button and the markup text display correctly as individual elements.

But I would like to replace the verify value in the submit element with the markup text. I cant just change the text because the markup is going to contain html.

Ive tried making the markup a variable, tried making it a child element. everything I can think of. But I just cant get the button to span around the markup.

Any advise is appriciated.

Thanks


Solution

  • $form['submit'] = array(
     '#type' => 'submit',
     '#value' => 'verify',
     '#tree' => TRUE,
     '#prefix' => '<div class="fancy-submit">',
     '#suffix' => '</div>',
    );
    

    I'm wondering why you don't use css with default classes to implement the styling though.