function entity_entity_property_edit_form_validate in Entity API 7
1 string reference to 'entity_entity_property_edit_form_validate'
- entity_property.inc in ctools/
relationships/ entity_property.inc - Plugin to provide an relationship handler for any entity property.
File
- ctools/
relationships/ entity_property.inc, line 108 - Plugin to provide an relationship handler for any entity property.
Code
function entity_entity_property_edit_form_validate($form, &$form_state) {
$context_key = $form_state['values']['context'];
$context = $form_state['contexts'][$context_key];
$entity_type = $context->type[2];
try {
$all_properties = entity_get_all_property_info($entity_type);
$wrapper = entity_metadata_wrapper($entity_type, NULL, array(
'property info' => $all_properties,
));
$parts = explode(':', $form_state['values']['selector']);
foreach ($parts as $part) {
if (!($wrapper instanceof EntityStructureWrapper || $wrapper instanceof EntityListWrapper)) {
form_set_error('selector', t('Unable to apply the data selector part %key.', array(
'%key' => $part,
)));
continue;
}
$wrapper = $wrapper
->get($part);
}
$type = entity_entity_property_map_data_type($wrapper
->type());
$form_state['conf']['target_context'] = $type;
} catch (EntityMetadataWrapperException $e) {
form_set_error('selector', t('Unable to apply the data selector on entity type %type. @reason', array(
'@reason' => $e
->getMessage(),
'%type' => $entity_type,
)));
}
// Auto-generate a sane identifier.
if ($form_state['values']['identifier'] == $form['identifier']['#default_value']) {
$form_state['values']['identifier'] = 'Entity property ' . $entity_type . ':' . check_plain($form_state['values']['selector']);
}
}