function eck_form_field_ui_field_overview_form_validate in Entity Construction Kit (ECK) 7.3
Validates the add property as extra field of field_ui_field_overview_form().
See also
eck_form_field_ui_field_overview_form_alter()
field_ui_field_overview_form_validate()
1 string reference to 'eck_form_field_ui_field_overview_form_validate'
- eck_form_field_ui_field_overview_form_alter in ./
eck.module - Adds a manage properties section.
File
- ./
eck.module, line 924
Code
function eck_form_field_ui_field_overview_form_validate($form, &$form_state) {
// The form element might be absent if no existing fields can be added to
// this bundle.
if (isset($form_state['values']['fields']['_eck_add_extra_field'])) {
$extra_field = $form_state['values']['fields']['_eck_add_extra_field'];
// Validate if any information was provided in the 'add existing field' row.
$array = array(
$extra_field['label'],
$extra_field['field_name'],
$extra_field['widget_type'],
);
if (array_filter($array)) {
// Missing label.
if (!$extra_field['label']) {
form_set_error('fields][_eck_add_extra_field][label', t('Add property as extra field: you need to provide a label.'));
}
// Missing existing field name.
if (!$extra_field['field_name']) {
form_set_error('fields][_eck_add_extra_field][field_name', t('Add property as extra field: you need to select a field.'));
}
// Wrong property for this bundle.
$entity_type = entity_type_load($form['#entity_type']);
if (!isset($entity_type->properties[$extra_field['field_name']])) {
form_set_error('fields][_eck_add_extra_field][field_name', t('Add property as extra field: invalid property for this bundle.'));
}
// Missing widget type.
if (!$extra_field['widget_type']) {
form_set_error('fields][_eck_add_extra_field][widget_type', t('Add property as extra field: you need to select a widget.'));
}
elseif ($extra_field['field_name'] && ($existing_field = field_info_field($extra_field['field_name']))) {
$entity_type = entity_type_load($form['#entity_type']);
$widget_types = eck_property_widget_type_options($entity_type->properties[$extra_field['field_name']]['type']);
if (!isset($widget_types[$extra_field['widget_type']])) {
form_set_error('fields][_eck_add_extra_field][widget_type', t('Add property as extra field: invalid widget.'));
}
}
}
}
}