function eck__property_add__form_submit in Entity Construction Kit (ECK) 7.3
Property add form.
File
- ./
eck.properties.inc, line 313 - Properties.
Code
function eck__property_add__form_submit($form, &$state) {
$values = $state['values'];
if (strcmp($values['op'], t('Select Property Type')) == 0) {
$state['rebuild'] = TRUE;
}
else {
// Lets save schema customization.
$default_schema = $values['default_schema'];
unset($values['default_schema']);
$new_schema = array();
// Lets get the values from the form.
foreach ($values as $name => $value) {
if (substr_count($name, "schema") > 0) {
$new_name = str_replace("schema_", "", $name);
if (strcmp($new_name, "unsigned") == 0 || strcmp($new_name, "not null") == 0) {
$value = $value ? TRUE : FALSE;
}
$new_schema[$new_name] = $value;
}
}
// If the default is empty lets take it off.
if (array_key_exists('default', $new_schema) && empty($new_schema['default'])) {
unset($new_schema['default']);
}
// Lets format the not null key to work with schema.
if (array_key_exists('not_null', $new_schema)) {
$temp = $new_schema['not_null'];
unset($new_schema['not_null']);
$new_schema['not null'] = $temp;
}
$entity_type_name = $values['entity_type_name'];
$entity_type = EntityType::loadByName($entity_type_name);
$entity_type
->addProperty($values['property_name'], $values['property_label'], $values['property_type'], NULL, $new_schema);
$entity_type
->save();
EntityType::loadAll(NULL, TRUE);
}
}