function token_field_field_settings in Token Field 6
Implementation of hook_field_settings().
File
- ./
token_field.module, line 36 - Optional extension to CCK (Content Construction Kit) to provide a read-only field which allows embedding of "compound" fields using Tokens.
Code
function token_field_field_settings($op, $field) {
switch ($op) {
case 'form':
$form = array();
// Hide multiple and required - this is a read only field
$form['multiple'] = $form['required'] = array(
'#type' => 'value',
);
$form['template'] = array(
'#tree' => TRUE,
);
$form['template']['parse_as_php'] = array(
'#type' => 'checkbox',
'#title' => t('Parse content as PHP?'),
'#description' => '<p>' . t('If this is enabled, the template will be parsed as PHP before any tokens are replaced. This allows you to define <em>optional</em> tokens by wrapping them in if statements.') . '</p>' . '<p>' . t('You will be able to access the <code>$node</code>, <code>$field</code>, <code>$items</code>, <code>$teaser</code> and <code>$page</code> variables, but you will not be able to modify them. You should wrap <code><?php</code> and <code>?></code> wrappers around any PHP code you add.') . '</p>' . '<p>' . t('For example: <code><php if ($node->field_example[0][\'value\'] == \'foo\') : print \'[field_example-formatted] | \'; endif; ?> [field_required_item-formatted]</code>') . '<p>',
'#default_value' => isset($field['template']['parse_as_php']) ? $field['template']['parse_as_php'] : FALSE,
);
$form['template']['body'] = array(
'#type' => 'textarea',
'#default_value' => isset($field['template']['body']) ? $field['template']['body'] : '',
'#description' => t('Using the text area, define the layout for this field using HTML and Tokens.'),
);
$form['template']['format'] = filter_form(isset($field['template']['format']) ? $field['template']['format'] : FILTER_FORMAT_DEFAULT, NULL, array(
'template',
'format',
));
$form['template']['token_help'] = array(
'#type' => 'markup',
'#value' => theme('token_tree', array(
'node',
'global',
)),
);
return $form;
case 'save':
return array(
'template',
);
}
}