function _content_field_overview_form_validate_add_existing in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 6.2 includes/content.admin.inc \_content_field_overview_form_validate_add_existing()
Helper function for content_field_overview_form_validate.
Validate the 'add existing field' row.
1 call to _content_field_overview_form_validate_add_existing()
File
- includes/
content.admin.inc, line 464 - Administrative interface for content type creation.
Code
function _content_field_overview_form_validate_add_existing($form, &$form_state) {
// The form element might be absent if no existing fields can be added to
// this content type
if (isset($form_state['values']['_add_existing_field'])) {
$field = $form_state['values']['_add_existing_field'];
// Validate if any information was provided in the 'add existing field' row.
if (array_filter(array(
$field['label'],
$field['field_name'],
$field['widget_type'],
))) {
// No label.
if (!$field['label']) {
form_set_error('_add_existing_field][label', t('Add existing field: you need to provide a label.'));
}
// No existing field.
if (!$field['field_name']) {
form_set_error('_add_existing_field][field_name', t('Add existing field: you need to select a field.'));
}
// No widget type.
if (!$field['widget_type']) {
form_set_error('_add_existing_field][widget_type', t('Add existing field: you need to select a widget.'));
}
elseif ($field['field_name'] && ($existing_field = content_fields($field['field_name']))) {
$widget_types = content_widget_type_options($existing_field['type']);
if (!isset($widget_types[$field['widget_type']])) {
form_set_error('_add_existing_field][widget_type', t('Add existing field: invalid widget.'));
}
}
}
}
}