function eck__properties__form_submit in Entity Construction Kit (ECK) 7.3
Same name and namespace in other branches
- 7.2 eck.properties.inc \eck__properties__form_submit()
Properties form submit callback.
File
- ./
eck.properties.inc, line 391 - Properties.
Code
function eck__properties__form_submit($form, &$state) {
if ($state['values']['op'] == t('Add Property')) {
$state['rebuild'] = TRUE;
}
elseif ($state['values']['op'] == t('Save')) {
// Here we want to add the properties to the entity type and save it.
$entity_type = $state['values']['entity_type'];
foreach ($state['values']['new_properties_table'] as $property => $active) {
if ($active) {
$info = $state['values']['new_properties'][$property];
if (array_key_exists('behavior', $info)) {
$entity_type
->addProperty($property, $info['label'], $info['type'], $info['behavior']);
}
else {
$entity_type
->addProperty($property, $info['label'], $info['type']);
}
}
else {
$entity_type
->removeProperty($property);
}
}
$entity_type
->save();
// Lets flush the cache so new behaviors and properties will get set up
// correctly.
// @todo do we need to replace this with our new caching strategy?
drupal_flush_all_caches();
}
}