Theming forms in Drupal 7

I provide how to theme Drupal 7 Forms. in this example is Drupal Commerce Checkout Form

—-
  template.php
—-

/**
 * Implementation of hook_theme
 * Define themes to make style
 */
function yourtheme_theme($existing, $type, $theme, $path) {
  $base = array(
    'arguments' => array('form' => NULL),
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'yourtheme') . '/templates/forms',
  );
 
  return array(
    'commerce_checkout_form_checkout' => $base + array(
      'template' => 'commerce-checkout-form-checkout',
    ),
  );
}
 
/**
 * Preprocessor for commerce_checkout_form_checkout theme
 */
function yourtheme_preprocess_commerce_checkout_form_checkout(&$variables) {
  /* Stuff with your variables */
}

—-
[yourtheme]/templates/forms/commerce-checkout-form-checkout.tpl.php
—-

<?php
  // stuff with $form
?>
Override
Advertisements

2 responses to “Theming forms in Drupal 7

  • Rafael

    I was suggested this blog via my cousin. I am not positive whether this submit is written by way of him as
    no one else realize such detailed about my difficulty.
    You’re amazing! Thank you!

  • Otilia

    I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get bought an nervousness over that you wish be delivering the following. unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you shield this hike.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: