You are here

function properties_widget_add_category_submit in Dynamic properties 7

Submit callback to add a category.

1 string reference to 'properties_widget_add_category_submit'
properties_field_widget_form in ./properties.module
Implements hook_field_widget_form().

File

./properties.module, line 594
This module provides a dynamic property field that can contain an unlimited number of attribute value pairs.

Code

function properties_widget_add_category_submit($form, &$form_state) {
  $field_name = $form_state['triggering_element']['#parents'][0];
  $langcode = $form[$field_name]['#language'];
  $values = $form_state['values'][$field_name][$langcode]['actions'];
  if (!isset($form_state[$field_name]['categories'][$values['new_category']])) {
    if (!properties_widget_add_category($values['new_category'], $form_state, $field_name, $langcode)) {
      drupal_set_message(t('Category empty or invalid.'), 'error');
    }
  }
  $form_state['rebuild'] = TRUE;
}