Kiểm tra tại đây
4. Next step is to create a hook_theme() function to theame these forms.
function custom_salesforce_theme() {
return array(
// this template is containing theme style for update form
'custom_salesforce_update_form' => array(
'template' => 'theme/custom_salesforce_update_form',
'render element' => 'form',
),
// this template is containing theme style for login form
'custom_salesforce_login_form' => array(
'template' => 'theme/custom_salesforce_login_form',
'render element' => 'form',
),
// this template is containing theme style for both forms
'custom_salesforce_login_and_update' => array(
'template' => 'theme/custom_salesforce_login_and_update',
'arguments' => array('combine_form' => NULL),
),
);
}
Note- Don't forget to create three template files inside theme folder inside your module.
5. Next step to write template preprocessor functions to display individual fields in separate template files.
/**
* Implements Template Preprocessor For User Login().
*/
function template_preprocess_custom_salesforce_login_form(&$variables) {
$variables['rtc_registered_email'] = drupal_render($variables['form']['rtc_registered_email']);
$variables['rtc_password'] = drupal_render($variables['form']['rtc_password']);
$variables['rtc_submit_form'] = drupal_render_children($variables['form']);
}
Mã trên mô tả cách bạn có thể thêm hai biểu mẫu.
Dưới đây
là cách bạn thêm nó vào tập tin tpl
<?php
$form = drupal_get_form('user_register_form');
print drupal_render($form);
?>
Hy vọng nó giúp :)