You are here

function editor_note_confirm_edit_form_validate_update in Editor Notes 7

Validates value of 'Create a note' textarea during updating a note via ajax.

1 string reference to 'editor_note_confirm_edit_form_validate_update'
editor_note_confirm_edit_form in ./editor_note.pages.inc
Builds confirmation form for editing the note which displays in popup.

File

./editor_note.pages.inc, line 146
Page callbacks defined in hook_menu for the Editor Notes module.

Code

function editor_note_confirm_edit_form_validate_update(&$form, &$form_state) {
  $text_processing = FALSE;
  $note = $form_state['values']['note'];
  $field_name = $form_state['values']['note_field_name'];
  $field = field_info_field($field_name);
  $field_info = field_info_instance($form_state['values']['note_entity_type'], $field_name, $form_state['values']['note_bundle']);
  if (isset($field_info['settings']['text_processing']) && $field_info['settings']['text_processing'] != EDITOR_NOTE_DEFAULT_TEXT_FORMAT) {
    $text_processing = TRUE;
  }

  // Maxlength check applies for plain text only.
  if (!$text_processing) {
    if (!empty($note) && $field['settings']['notes_maxlength'] > 0) {
      if (drupal_strlen($note) > $field['settings']['notes_maxlength']) {
        form_set_error('note', t('%name: the value cannot not be longer than %max characters.', array(
          '%name' => $field_info['label'],
          '%max' => $field['settings']['notes_maxlength'],
        )));
      }
    }
  }
}