You are here

function conditional_fields_forms_submit in Conditional Fields 6.2

Same name and namespace in other branches
  1. 5 conditional_fields.module \conditional_fields_forms_submit()
  2. 6 conditional_fields.module \conditional_fields_forms_submit()

Handle saving of conditional field settings. The controlled field can be either a field or a group

2 string references to 'conditional_fields_forms_submit'
conditional_fields_content_admin_field in ./conditional_fields.module
Alteration of the field editing form
conditional_fields_fieldgroup_group_edit_form in ./conditional_fields.module
Alteration of the fieldgroup editing form

File

./conditional_fields.module, line 602
Content fields and groups visibility based on the values of user defined 'trigger' fields.

Code

function conditional_fields_forms_submit($form, &$form_state) {
  $controlled_field = isset($form_state['values']['field_name']) ? $form_state['values']['field_name'] : $form_state['values']['group_name'];
  $type = isset($form['#field']['type_name']) ? $form['#field']['type_name'] : $form['#content_type']['type'];
  conditional_fields_save_field($type, $controlled_field, $form_state['values']['conditional_fields']['available_fields']);

  // Fields already controlled should share the same settings of their controlling fields
  if (!empty($form_state['values']['controlled_fields'])) {
    foreach ($form_state['values']['controlled_fields'] as $field_name => $trigger_values) {
      conditional_fields_save_field($type, $field_name, $form_state['values']['conditional_fields']['available_fields']);
    }
  }
}