Last active
September 5, 2015 18:49
-
-
Save henrytran9x/2f4c672a8c91c4863d2d to your computer and use it in GitHub Desktop.
This module example template render form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = My Module | |
description = This module exmaple | |
core = 7.x | |
version = 1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Implements hook_theme() | |
*/ | |
function my_module_theme() | |
{ | |
$items['page_user_edit_add_form'] = array( | |
'render element' => 'form', | |
'template' => 'page-user-edit', | |
'path' => drupal_get_path('module', 'my_module'), | |
); | |
return $items; | |
} | |
/** | |
* Implements hook_menu(). | |
*/ | |
function my_module_menu() | |
{ | |
$items['admin/henry'] = array( | |
'title' => 'Henry Module', | |
'page callback' => 'drupal_get_form', | |
'page arguments' => array('page_user_edit_add_form'), | |
'access arguments' => array('access content'), | |
'type' => MENU_NORMAL_ITEM, | |
); | |
return $items; | |
} | |
/* | |
* Create form | |
*/ | |
function page_user_edit_add_form($form, &$form_state){ | |
$form = array(); | |
$form['hovaten'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Fullname'), | |
'#description' => t('This field input fullname') | |
); | |
$form['submit'] = array('#type' => 'submit', '#value' => t('Save')); | |
return $form; | |
} | |
/* | |
* Process submit form | |
*/ | |
function page_user_edit_add_form_submit($form, &$form_state){ | |
//code submit | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $form = drupal_get_form('page_user_edit_add_form'); Không nên làm cách này | |
print '<form id="'.$form['#id'].'" accept-charset="UTF-8" method="'.$form['#method'].'" action="'.$form['#action'].'">'; | |
print render($form['hovaten']); | |
print render($form['submit']); | |
print drupal_render_children($form); | |
print '</form>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment