On this page
function field_ui_widget_type_form_submit
field_ui_widget_type_form_submit($form, &$form_state)
Form submission handler for field_ui_widget_type_form().
File
- modules/field_ui/field_ui.admin.inc, line 1697
- Administrative interface for custom field type creation.
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);
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field_ui!field_ui.admin.inc/function/field_ui_widget_type_form_submit/7.x