function media_element_validate in D7 Media 7.4
Same name and namespace in other branches
- 7 media.module \media_element_validate()
- 7.2 media.module \media_element_validate()
- 7.3 media.module \media_element_validate()
Validate media form elements.
The file type is validated during the upload process, but this is necessary necessary in order to respect the #required property.
1 string reference to 'media_element_validate'
- media_element_info in ./
media.module - Implements hook_element_info().
File
- ./
media.module, line 961 - Media API
Code
function media_element_validate(&$element, &$form_state) {
$clicked_button = end($form_state['triggering_element']['#parents']);
// Check required property based on the FID.
if ($element['#required'] && empty($element['fid']['#value']) && !in_array($clicked_button, array(
'attach_button',
'remove_button',
))) {
form_error($element['browse_button'], t('!name field is required.', array(
'!name' => $element['#title'],
)));
}
// Consolidate the array value of this field to a single FID.
if (!$element['#extended']) {
form_set_value($element, $element['fid']['#value'], $form_state);
}
}