function _fences_form_views_ui_config_item_form_alter in Fences 7
Same name and namespace in other branches
- 7.2 fences.admin.inc \_fences_form_views_ui_config_item_form_alter()
Implements hook_form_FORM_ID_alter().
Alter the views field item form to change some of the default values. Note: we only act on an item if it is among the list of fields added to the view's fences_new_fields property in _fences_views_ui_add_item_form_submit().
1 call to _fences_form_views_ui_config_item_form_alter()
- fences_form_views_ui_config_item_form_alter in ./
fences.module - Implements hook_form_FORM_ID_alter().
File
- ./
fences.admin.inc, line 276 - Functions only needed on configuration pages.
Code
function _fences_form_views_ui_config_item_form_alter(&$form, &$form_state) {
// Check if the current item is a field.
if ($form_state['type'] == 'field' && isset($form_state['view']->fences_new_fields)) {
if (!empty($form_state['view']->fences_new_fields)) {
// Check if the current item is one of the fields we marked earlier.
$key = array_search($form_state['id'], $form_state['view']->fences_new_fields);
if ($key !== FALSE) {
// Disable the label option.
$form['options']['custom_label']['#default_value'] = FALSE;
// Since we are altering this fieldset's defaults, expand it.
$form['options']['style_settings']['#collapsed'] = FALSE;
// Enable the element_type style to be none.
$form['options']['element_type_enable']['#default_value'] = TRUE;
$form['options']['element_type']['#default_value'] = 0;
// Enable the element_wrapper style to be none.
$form['options']['element_wrapper_type_enable']['#default_value'] = TRUE;
$form['options']['element_wrapper_type']['#default_value'] = 0;
// Disable the default element classes.
$form['options']['element_default_classes']['#default_value'] = FALSE;
// Set the field settings to use the field_api for rendering.
$form['options']['field_api_classes']['#default_value'] = TRUE;
// Remove this field from the list of items to alter.
unset($form_state['view']->fences_new_fields[$key]);
}
}
// Remove the temporary property set when we added items.
if (empty($form_state['view']->fences_new_fields)) {
unset($form_state['view']->fences_new_fields);
}
}
}