function properties_widget_add_attribute_submit in Dynamic properties 7
Submit callback to add an attribute.
1 string reference to 'properties_widget_add_attribute_submit'
- properties_field_widget_form in ./
properties.module - Implements hook_field_widget_form().
File
- ./
properties.module, line 649 - This module provides a dynamic property field that can contain an unlimited number of attribute value pairs.
Code
function properties_widget_add_attribute_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'];
$attribute = properties_attribute_load($values['new_attribute']);
if (!empty($attribute)) {
$form_state[$field_name]['categories'][$values['attribute_category']]['properties'][$attribute->name] = array(
'attribute' => $attribute->name,
'category' => $values['attribute_category'],
'value' => '',
'_weight' => count($form_state[$field_name]['categories'][$values['attribute_category']]['properties']),
);
// Clear the new category form field.
unset($form_state['input'][$field_name][$langcode]['new_attribute']);
}
else {
drupal_set_message(t('Attribute empty or invalid.'), 'error');
}
$form_state['rebuild'] = TRUE;
}