martes, 21 de julio de 2009

How to theme a Drupal Form

http://agaric.com/note/how-theme-drupal-form
----------------------- search_jobs_form.tpl.php -------------------------

print drupal_render($form['job_key']);
print drupal_render($form['job_location']);
print drupal_render($form['submit']);



<?php print drupal_render($form['name']); ?>

<?php print drupal_render($form['mail']); ?>

<?php print drupal_render($form['pass']); ?>

<?php print drupal_render($form['field_user_picture']); ?>

<?php print drupal_render($form['field_city']); ?>


---------- MODULE FUNCTION ----------------

function search_jobs_form() {
    $form['job_key'] = array(
'#title' => t('What?'),
'#type' => 'textfield',
'#description' => t('Enter keywords (e.g.,sales, java, nurse).'),
    );
    $form['job_location'] = array(
'#title' => t('Where?'),
'#type' => 'textfield',
'#description' => t('e.g. San Diego, CA.'),
    );
    $form['submit'] = array(
'#type' => 'submit',
'#value' => t('')
    );
 //   $form['#action'] = 'jobs';
    return $form;
}

--------------THEME FUNCTION -----------------
function rb_helper_theme() {
  return array(
    'search_jobs_form' => array(
      'template' => 'search_jobs_form',
      'arguments' => array('form' => NULL),
    ),
  );
}

No hay comentarios: