function viewfield_select_process in Viewfield 6
Same name and namespace in other branches
- 6.2 viewfield.module \viewfield_select_process()
1 string reference to 'viewfield_select_process'
- viewfield_elements in ./viewfield.module
- Implementation of FAPI hook_elements().
File
- ./viewfield.module, line 194
- Core functions.
Code
function viewfield_select_process($element, $edit, $form_state, $form) {
$field = isset($form['#field_info'][$element['#field_name']]) ? $form['#field_info'][$element['#field_name']] : NULL;
$element['#field_info'] = isset($form['#field_info']) ? $form['#field_info'] : NULL;
$node = isset($form['#node']) ? $form['#node'] : (object) array(
'type' => $field['type_name'],
);
$field_settings = !isset($node->uid);
if ($field['widget']['force_default'] && !$field_settings) {
$element['vname'] = array(
'#type' => 'value',
'#value' => $element['#default_value']['vname'],
);
$element['vargs'] = array(
'#type' => 'value',
'#value' => $element['#default_value']['vargs'],
);
}
else {
$options = _viewfield_potential_references($field, $element['#delta']);
if ($field['super_default'] && !$field_settings) {
$element['override_default'] = array(
'#type' => 'checkbox',
'#title' => t('Override default'),
'#default_value' => $element['#value']['override_default'],
);
}
if (count($options) > 1) {
$element['vname'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => isset($element['#default_value']['vname']) ? $element['#default_value']['vname'] : NULL,
'#title' => $element['#title'],
'#required' => $element['#required'],
'#description' => $element['#description'],
);
}
else {
list($key, $label) = each($options);
$element['vname'] = array(
'#type' => 'value',
'#value' => $key,
);
}
$element['vargs'] = array(
'#type' => 'textfield',
'#title' => !isset($label) ? t('Arguments') : t('%field (@value) arguments', array(
'%field' => $field['widget']['label'],
'@value' => $label,
)),
'#default_value' => isset($element['#default_value']['vargs']) ? $element['#default_value']['vargs'] : NULL,
'#required' => FALSE,
'#description' => t('Provide a comma separated list of arguments to pass to the view. These arguments will be passed to EACH selected view. If an argument contains commas or double quotes, enclose it in double quotes. Replace double quotes that are part of the argument with pairs of double quotes.'),
);
$token_desc = ($token_enabled = _viewfield_token_enabled($field)) ? t('Use the syntax [token] if you want to insert a replacement pattern.') : t('You may use %nid for the node id of the current node. %author for the node author and %viewer for user viewing the node.');
$element['vargs']['#description'] .= "<br/>\n{$token_desc}";
if ($token_enabled && ($field_settings || !$field['multiple'])) {
$element['token_help'] = _viewfield_get_token_help($field);
}
}
return $element;
}