form_learning.info
; Form Module
name = Form Learning
description = Provide Learning For Form Module
package = Learning
version = 1.0
core = 7.x
name = Form Learning
description = Provide Learning For Form Module
package = Learning
version = 1.0
core = 7.x
And here's the code of the module. form_learning.module
<?php
/**
* Implements drupal hook_menu()
*
* page argument is the most significant one. it's a reference
* to function that we write as form page (form provider)
* page callback must written as drupal_get_form
**/
function form_learning_menu(){
$items = array();
$items['learning/form'] = array(
'title' => 'Form Learning',
'page callback' => 'drupal_get_form',
'page arguments' => array('form_1'),
'access callback' => TRUE,
);
return $items;
}
/**
* This is the function that supply the form.
* The function arguments should match like these one.
*/function form_1($form, &$form_state){
$form['description'] = array(
'#type' => 'item',
'#title' => t('This is the first entry of form'),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
);
return $form;
}
No comments:
Post a Comment