You are here

function widgets_set_form_add_submit in Widgets 7

Submit handler for adding a new widget element to an widget set.

1 string reference to 'widgets_set_form_add_submit'
widgets_set_form in ./widgets.admin.inc
Form builder; Edit an widget set name and elements order.

File

./widgets.admin.inc, line 370
Administration pages for widget settings.

Code

function widgets_set_form_add_submit($form, &$form_state) {
  $set = $form_state['widgets_set'];

  // Check if this field has any configuration options.
  $element = widgets_element_definition_load($form_state['values']['new']);

  // Load the configuration form for this option.
  if (isset($element['form callback'])) {
    $path = 'admin/structure/widgets/sets/edit/' . $form_state['widgets_set']['name'] . '/add/' . $form_state['values']['new'];
    $form_state['redirect'] = array(
      $path,
      array(
        'query' => array(
          'weight' => $form_state['values']['weight'],
        ),
      ),
    );
  }
  else {
    $element['wsid'] = $set['wsid'];
    $element['weight'] = $form_state['values']['weight'];
    widgets_element_save($element);
    drupal_set_message(t('The widget element was successfully added.'));
  }

  // clear caches
  $scope = isset($set['data']['cache']['scope']) ? $set['data']['cache']['scope'] : '';
  $cid = widgets_build_cache_cid($set['name'], $scope);
  widgets_clear_widgets_cache($cid);
}