function token_custom_edit_form in Custom Tokens 5
Same name and namespace in other branches
- 6 token_custom.module \token_custom_edit_form()
- 7.2 token_custom.admin.inc \token_custom_edit_form()
- 7 token_custom.admin.inc \token_custom_edit_form()
2 string references to 'token_custom_edit_form'
File
- ./
token_custom.module, line 226
Code
function token_custom_edit_form($tkid = null) {
if ($tkid) {
$token = _token_custom_load($tkid);
$form['token_custom_tkid'] = array(
'#type' => 'value',
'#value' => $tkid,
);
}
$form['token_custom_id'] = array(
'#type' => 'textfield',
'#title' => t('Token ID'),
'#description' => t('Machine name of the token ID. It must start with token_custom_'),
'#default_value' => $tkid ? $token->id : 'token_custom_',
'#required' => TRUE,
);
$form['token_custom_description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('Description that will appear in the token\'s help.'),
'#default_value' => $tkid ? $token->description : null,
'#required' => TRUE,
);
$options = array();
$options['global'] = t('Global');
$options['node'] = t('Node');
$options['user'] = t('User');
$options['taxonomy'] = t('Taxonomy');
$options['comment'] = t('Comment');
$form['token_custom_type'] = array(
'#type' => 'radios',
'#title' => t('Type'),
'#description' => t('Select the type of the token you would like to add. Depending on the type you\'ll have access to the specific object in your php code.'),
'#required' => TRUE,
'#options' => $options,
'#default_value' => $tkid ? $token->type : null,
);
$form['token_custom_php'] = array(
'#type' => 'textarea',
'#title' => t('PHP replacement'),
'#description' => t('Enter the php code that will be evaluated. You do not need to enclose the code between %php. You have $user, $comment, $node and $taxonomy available depending on the type. You have also the variable $type which the actual type of token. Global has no particular object to use. The code should return a string.', array(
'%php' => '<?php ?>',
)),
'#required' => TRUE,
'#default_value' => $tkid ? $token->php : null,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
if ($tkid) {
$form['delete'] = array(
'#type' => 'button',
'#value' => t('Delete'),
'#weight' => 50,
);
}
return $form;
}