You are here

function ds_code_field_form_submit in Display Suite 6.3

Same name and namespace in other branches
  1. 6 includes/ds.fields.inc \ds_code_field_form_submit()
  2. 6.2 includes/ds.fields.inc \ds_code_field_form_submit()

Save code field.

1 string reference to 'ds_code_field_form_submit'
ds_code_field_form in includes/ds.fields.inc
Code field form.

File

includes/ds.fields.inc, line 302
Manage fields.

Code

function ds_code_field_form_submit($form, &$form_state) {
  $module = $form['#module'];
  $fields = variable_get($module . '_fields', array());
  $key = $form_state['values']['code_key'];
  $fields[$key] = array(
    'title' => $form_state['values']['code_title'],
    'exclude' => $form_state['values']['code_exclude'],
    'type' => DS_FIELD_TYPE_CODE,
    'status' => $form['#field_status'],
    'properties' => array(
      'formatters' => array(
        'ds_eval_code' => t('Default'),
      ),
      'code' => $form_state['values']['code_code'],
      'token' => $form_state['values']['code_token'],
    ),
  );

  // Code class.
  if (!empty($form_state['values']['code_class'])) {
    $fields[$key]['properties']['css-class'] = $form_state['values']['code_class'];
  }

  // Safe field and invalidate cached fields.
  variable_set($module . '_fields', $fields);
  ds_reset_fields_cache();

  // Redirect and confirmation message.
  $form_state['redirect'] = DS_PATH_MODULES . '/' . $form['#module'] . '/fields';
  drupal_set_message(t('Field %field has been saved.', array(
    '%field' => $form_state['values']['code_title'],
  )));
}