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
form_learning.module
<?php
/**
* Implements drupal hook_menu()
*/
function form_learning_menu(){
$items = array();
/**
* Main menu in the navigation block
*/
$items['learning/form'] = array(
'title' => 'Form Learning',
'page callback' => 'desc',
'access callback' => TRUE,
);
/**
* Primary menu tab
* Show item, textbox, submit and fieldset
*/
$items['learning/form/data'] = array(
'title' => 'Personal Data',
'page callback' => 'drupal_get_form',
'page arguments' => array('get_data'),
'type' => MENU_LOCAL_TASK,
'access callback' => TRUE,
'weight' => 1,
);
$items['learning/form/choice'] = array(
'title' => 'Choice',
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('get_choice'),
'access callback' => TRUE,
'weight' => 2,
);
return $items;
}
function desc(){
return t('In the next tab you will find other kinds of form implementations');
}
/**
* The primary tab menu (not default)
*/
function get_data($form, &$form_state){
/**
* Just showing the description text
*/
$form['description'] = array(
'#type' => 'item',
'#title' => t('A form with fieldset'),
);
/**
* Fielset First: Pesonal Data
*/
$form['data'] = array(
'#type' => 'fieldset',
'#title' => t('Personal Information'),
);
$form['data']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
);
$form['data']['city'] = array(
'#type' => 'textfield',
'#title' => t('City'),
);
$form['data']['key'] = array(
'#type' => 'password',
'#title' => 'Your PIN',
);
$form['data']['submit'] = array(
'#type' => 'submit',
'#value' => 'Send',
);
return $form;
}
function get_choice($form, &$form_state){
$form['desc'] = array(
'#type' => 'item',
'#title' => t('This page show demonstration on how to build your choice form'),
);
$form['choice'] = array(
'#type' => 'fieldset',
'#title' => t('Choice Available'),
);
/**
* Implements radio button
*/
$form['choice']['gender'] = array(
'#type' => 'radios',
'#options' => drupal_map_assoc(array(t('Male'),
/**
* Implements drupal hook_menu()
*/
function form_learning_menu(){
$items = array();
/**
* Main menu in the navigation block
*/
$items['learning/form'] = array(
'title' => 'Form Learning',
'page callback' => 'desc',
'access callback' => TRUE,
);
/**
* Primary menu tab
* Show item, textbox, submit and fieldset
*/
$items['learning/form/data'] = array(
'title' => 'Personal Data',
'page callback' => 'drupal_get_form',
'page arguments' => array('get_data'),
'type' => MENU_LOCAL_TASK,
'access callback' => TRUE,
'weight' => 1,
);
$items['learning/form/choice'] = array(
'title' => 'Choice',
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('get_choice'),
'access callback' => TRUE,
'weight' => 2,
);
return $items;
}
function desc(){
return t('In the next tab you will find other kinds of form implementations');
}
/**
* The primary tab menu (not default)
*/
function get_data($form, &$form_state){
/**
* Just showing the description text
*/
$form['description'] = array(
'#type' => 'item',
'#title' => t('A form with fieldset'),
);
/**
* Fielset First: Pesonal Data
*/
$form['data'] = array(
'#type' => 'fieldset',
'#title' => t('Personal Information'),
);
$form['data']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
);
$form['data']['city'] = array(
'#type' => 'textfield',
'#title' => t('City'),
);
$form['data']['key'] = array(
'#type' => 'password',
'#title' => 'Your PIN',
);
$form['data']['submit'] = array(
'#type' => 'submit',
'#value' => 'Send',
);
return $form;
}
function get_choice($form, &$form_state){
$form['desc'] = array(
'#type' => 'item',
'#title' => t('This page show demonstration on how to build your choice form'),
);
$form['choice'] = array(
'#type' => 'fieldset',
'#title' => t('Choice Available'),
);
/**
* Implements radio button
*/
$form['choice']['gender'] = array(
'#type' => 'radios',
'#options' => drupal_map_assoc(array(t('Male'),
t('Female'))),
'#title' => t('Your Gender'),
);
/**
* Implements checkbox
*/
$form['choice']['fruit'] = array(
'#type' => 'checkboxes',
'#title' => t('Your favorit fruit'),
'#options' => drupal_map_assoc(array(t('Apple'),
'#title' => t('Your Gender'),
);
/**
* Implements checkbox
*/
$form['choice']['fruit'] = array(
'#type' => 'checkboxes',
'#title' => t('Your favorit fruit'),
'#options' => drupal_map_assoc(array(t('Apple'),
t('Bananas'), t('Orange'), t('Gueva'), t('Papaya'))),
);
/**
* Implements combo box
*/
$form['choice']['country'] = array(
'#type' => 'select',
'#title' => t('Where you live?'),
'#options' => array(
1 => t('Japan'),
2 => t('Qatar'),
3 => t('New Zealand'),
4 => t('Indonesia'),
5 => t('Malaysia'),
),
);
/**
* Place this button on outer of fieldset
*/
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send'),
);
return $form;
}
);
/**
* Implements combo box
*/
$form['choice']['country'] = array(
'#type' => 'select',
'#title' => t('Where you live?'),
'#options' => array(
1 => t('Japan'),
2 => t('Qatar'),
3 => t('New Zealand'),
4 => t('Indonesia'),
5 => t('Malaysia'),
),
);
/**
* Place this button on outer of fieldset
*/
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send'),
);
return $form;
}
No comments:
Post a Comment