Paste: for vasea :-)
Author: | ina |
Mode: | php |
Date: | Wed, 3 Nov 2010 09:29:22 |
Plain Text |
<?php
function A_node_info() {
return array(
'node_example' => array(
'name' => t('contentA'),
'module' => 'A',
'description' => "This is a test node type with a few fields.",
)
);
}
function A_perm() {
return array('access test content');
}
function A_access($op, $node) {
global $user;
if ($op == 'create') {
return user_access('create test');
}
if ($op == 'update' || $op == 'delete') {
if (user_access('edit own test') && ($user->uid == $node->uid)) {
return TRUE;
}
}
}
function A_form(&$node, $form_state) {
$form['test'] = array(
'#type' => 'fieldset',
'#title' => t('Simple form'),
'#tree' => true,
);
$form['test']['domains'] = array(
'#type' => 'select',
'#title' => t('Domains'),
'#options' => array(
'0' => t('Informatics'),
'1' => t('Matematics'),
'2' => t('Foreign languages'),
),
'#multiple' => true,
'#required' => true
);
$form['test']['gender'] = array(
'#type' => 'radios',
'#title' => t('Gender'),
'#options' => array(t('Male'), t('Female')),
);
$form['test']['note'] = array(
'#type' => 'textarea',
'#title' => t('Notes'),
'#required' => true
);
$form['test']['email'] = array(
'#type' => 'textfield',
'#title' => t('E-mail'),
'#default_value' => '',
'#size' => 60,
'#required' => true,
);
$form['test']['agree'] = array(
'#type' => 'checkboxes',
'#options' => array(0 => t('I agree')),
);
$form['test']['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
$form['test']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
return $form;
}
function A_form_validate($form, &$form_state) {
die('we got here');
if ($form_state['values']['test']['gender'] == 'Male') {
form_set_error('', t('You must select female'));
}
}
New Annotation