function eck__property_behavior__form in Entity Construction Kit (ECK) 7.3
Property behavior form.
1 string reference to 'eck__property_behavior__form'
- eck__bundle__menu in ./
eck.bundle.inc - This function creates the menu items relevant to bundle administration.
File
- ./
eck.property_behavior.inc, line 164 - Property Behaviors.
Code
function eck__property_behavior__form($form, &$state, $entity_type_name, $property) {
$entity_type = EntityType::loadByName($entity_type_name);
$properties = $entity_type->properties;
if (array_key_exists($property, $properties)) {
$form['entity_type'] = array(
'#type' => 'value',
'#value' => $entity_type,
);
$form['property'] = array(
'#type' => 'value',
'#value' => $property,
);
ctools_include("plugins");
$plugins = ctools_get_plugins("eck", "property_behavior");
$behaviors = array(
'_ NONE _',
);
$behaviors = array_merge($behaviors, array_keys($plugins));
$form['behaviors'] = array(
'#type' => 'value',
'#value' => $behaviors,
);
$key = array_search($properties[$property]['behavior'], $behaviors);
// We can have 3 possible states,
// 1) there is no behavior for the property and non has been selected for
// configuration.
// 2) there is no behavior for the property, but one has been chosen to be
// configured.
// 3) This property has a behavior already.
// Has a behavior been selected?
$behavior = FALSE;
if (array_key_exists('values', $state)) {
$values = $state['values'];
$behavior = $values['behavior'];
}
if (!$key && !$behavior) {
$form['behavior'] = array(
'#title' => 'behavior',
'#type' => 'select',
'#options' => $behaviors,
'#default_value' => $key,
);
$form['configure'] = array(
'#type' => 'submit',
'#weight' => 10000,
'#value' => t('Configure'),
);
}
elseif (!$key && $behavior) {
$form['behavior'] = array(
'#title' => 'behavior',
'#type' => 'select',
'#options' => $behaviors,
'#default_value' => $key,
);
// Need to get the behaviors configuration form.
$behavior_name = $behaviors[$behavior];
$function = ctools_plugin_get_function($plugins[$behavior_name], "config_form");
if ($function) {
$config_form = $function();
foreach ($config_form as $key => $element) {
unset($config_form[$key]);
$config_form["config_{$key}"] = $element;
}
}
if (isset($config_form)) {
$form['config_form_wrapper'] = array(
'#type' => 'fieldset',
'#title' => "Configure Behavior",
);
$form['config_form_wrapper']['config_form'] = $config_form;
}
$form['submit'] = array(
'#type' => 'submit',
'#weight' => 10000,
'#value' => t('Save'),
);
}
else {
$form['behavior'] = array(
'#markup' => "<h3>{$behaviors[$key]}</h3>",
);
$form['remove'] = array(
'#type' => 'submit',
'#weight' => 10000,
'#value' => t('Remove'),
);
}
}
else {
drupal_set_message('This property does not exists');
drupal_goto(eck__entity_type__path() . "/{$entity_type->name}/property");
}
return $form;
}