You are here

function paragraphs_bundle_settings_form_submit in Paragraphs 7

Submit callback for paragraphs bundle settings form.

See also

paragraphs_form_field_ui_field_edit_form_alter

1 string reference to 'paragraphs_bundle_settings_form_submit'
paragraphs_form_field_ui_field_edit_form_alter in ./paragraphs.module
Implements hook_form_field_ui_field_edit_form_alter().

File

./paragraphs.module, line 420
Paragraphs hooks and common functions.

Code

function paragraphs_bundle_settings_form_submit($form, &$form_state) {
  $bundle_settings = array();
  $bundle_weights = array();
  if (isset($form_state['values']['instance']['settings']['allowed_bundles_table'])) {
    $bundle_settings_table = $form_state['values']['instance']['settings']['allowed_bundles_table'];
    uasort($bundle_settings_table, 'drupal_sort_weight');
    foreach ($bundle_settings_table as $machine_name => $value) {
      $bundle_settings[$machine_name] = $value['enabled'] === 1 ? $machine_name : -1;
      $bundle_weights[$machine_name] = $value['weight'];
    }
  }
  $form_state['values']['instance']['settings']['allowed_bundles'] = $bundle_settings;
  $form_state['values']['instance']['settings']['bundle_weights'] = $bundle_weights;
  unset($form_state['values']['instance']['settings']['allowed_bundles_table']);
}