function editableviews_handler_field_field_edit::edit_form_validate in Editable Views 7
Handle the form validation for this field's form element.
Parameters
$entity_type: The entity type.
$entity: The entity.
&$element: The partial form, at $form[ENTITY_ID].
&$form_state: The form state.
&$errors: An array of errors, in the same format as expected by hook_field_attach_validate().
File
- handlers/
editableviews_handler_field_field_edit.inc, line 169
Class
- editableviews_handler_field_field_edit
- Field handler for toggling between rendered value and edit form element.
Code
function edit_form_validate($entity_type, $entity, &$element, &$form_state, &$errors) {
list($entity_id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$field_name = $this->definition['field_name'];
$field_instance = field_info_instance($entity_type, $field_name, $bundle);
// Because a View result can show entities of different bundles, it is
// essential that we check the field actually exists on the current entity.
// ctools_field_invoke_field() does actually check for this too, but that
// only works when it's passed a field name rather than a whole instance.
if (empty($field_instance)) {
return;
}
// Extract field values from submitted values.
// We pass a partial $form array to the Field API hook. This contains at
// its base the #parents array, which tells Field API where to look for
// the values in $form_state.
ctools_field_invoke_field_default($field_instance, 'extract_form_values', $entity_type, $entity, $element, $form_state);
// Check generic, field-type-agnostic errors first.
ctools_field_invoke_field_default($field_instance, 'validate', $entity_type, $entity, $errors);
// Check field-type specific errors.
ctools_field_invoke_field($field_instance, 'validate', $entity_type, $entity, $errors);
}