function manualcrop_field_widget_form_alter in Manual Crop 7
Implements hook_field_widget_form_alter().
File
- ./
manualcrop.module, line 234
Code
function manualcrop_field_widget_form_alter(&$element, &$form_state, $context) {
if (user_access('use manualcrop')) {
$widget = $context['instance']['widget'];
if (manualcrop_supported_widgets($widget['type'])) {
if (!empty($widget['settings']['manualcrop_enable'])) {
$after_build = FALSE;
if ($widget['type'] == 'media_generic') {
$after_build = !_manualcrop_media_element_add_after_build($element);
}
foreach (element_children($element) as $key) {
$element[$key]['#process'][] = 'manualcrop_widget_process';
$element[$key]['#element_validate'][] = 'manualcrop_croptool_validate';
if ($widget['type'] == 'media_generic') {
$element[$key]['#element_validate'][] = 'media_element_validate';
}
elseif ($widget['type'] != 'media') {
$element[$key]['#element_validate'][] = 'file_managed_file_validate';
}
if ($after_build) {
_manualcrop_media_element_add_after_build($element[$key]);
}
}
_manualcrop_attach_files();
if (module_exists('insert')) {
$element['#after_build'][] = 'manualcrop_insert_element_process';
}
}
}
}
}