function field_ui_widget_type_form_submit

Form submission handler for field_ui_widget_type_form().

1 string reference to 'field_ui_widget_type_form_submit'
field_ui_widget_type_form in modules/field_ui/field_ui.admin.inc
Form constructor for the widget selection form.

File

modules/field_ui/field_ui.admin.inc, line 1710

Code

function field_ui_widget_type_form_submit($form, &$form_state) {
    $form_values = $form_state['values'];
    $bundle = $form['#bundle'];
    $entity_type = $form['#entity_type'];
    $field_name = $form['#field_name'];
    // Retrieve the stored instance settings to merge with the incoming values.
    $instance = field_read_instance($entity_type, $field_name, $bundle);
    // Set the right module information.
    $widget_type = field_info_widget_types($form_values['widget_type']);
    $widget_module = $widget_type['module'];
    $instance['widget']['type'] = $form_values['widget_type'];
    $instance['widget']['module'] = $widget_module;
    try {
        field_update_instance($instance);
        drupal_set_message(t('Changed the widget for field %label.', array(
            '%label' => $instance['label'],
        )));
    } catch (Exception $e) {
        drupal_set_message(t('There was a problem changing the widget for field %label.', array(
            '%label' => $instance['label'],
        )), 'error');
    }
    $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.