function availability_calendar_field_widget_month_form_validate in Availability Calendars 7.3
Same name and namespace in other branches
- 7.5 availability_calendar.widget.inc \availability_calendar_field_widget_month_form_validate()
- 7.4 availability_calendar.widget.inc \availability_calendar_field_widget_month_form_validate()
Callback to validate the calendar changes. @link http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
1 string reference to 'availability_calendar_field_widget_month_form_validate'
- availability_calendar_field_widget_month_form in ./
availability_calendar.widget.inc - Defines the form elements to edit this field.
File
- ./
availability_calendar.widget.inc, line 143
Code
function availability_calendar_field_widget_month_form_validate($element, &$form_state, $form) {
// Do not update on preview, only on a real submit.
// Drupal might have added additional characters to the #id to make it unique,
// so only check on the start of the #id.
$op = isset($form_state['clicked_button']) ? $form_state['clicked_button']['#id'] : '';
if (substr($op, 0, strlen('edit-submit')) === 'edit-submit') {
$changes = array();
$lines = explode("\n", $element['availability_changes']['#value']);
// Remove the last incomplete line.
array_pop($lines);
foreach ($lines as $line) {
if (!empty($line)) {
$change = availability_calendar_field_widget_month_form_validate_line($line, $element);
if ($change !== FALSE) {
$changes[] = $change;
}
else {
form_error($element, t('The requested calendar changes contain an invalid request.'));
break;
}
}
}
// If the field changes validated, store them for processing in the submit
// phase. In the submit phase our hook_field_attach_submit implementation
// will process the changes. As that hook operates on the entity, we need
// to be able to match these changes with the entity, field, language, and
// delta. We do so using the value of the cid_unique field.
if (!empty($changes) && $change !== FALSE) {
$form_state['availability_calendar_updates'][] = array(
$element['#field_name'],
$element['#language'],
$element['#delta'],
$element['cid_unique']['#value'],
$changes,
);
}
}
}