function editor_note_confirm_edit_form in Editor Notes 7
Builds confirmation form for editing the note which displays in popup.
1 string reference to 'editor_note_confirm_edit_form'
- editor_note_confirm_edit_page in ./
editor_note.pages.inc - Builds confirmation page for updating selected note.
File
- ./
editor_note.pages.inc, line 44 - Page callbacks defined in hook_menu for the Editor Notes module.
Code
function editor_note_confirm_edit_form($form, $form_state, $note_id = NULL) {
$form = array();
$note_id = isset($note_id) ? $note_id : (int) arg(4);
$note = editor_note_load($note_id);
if ($note) {
$field = field_info_field($note->field_name);
$field_instance = field_info_instance($note->entity_type, $note->field_name, $note->bundle);
$text_processing = !empty($field['settings']['text_processing']) ? $field['settings']['text_processing'] : EDITOR_NOTE_DEFAULT_TEXT_FORMAT;
// Defines whether form has been opened via ajax or via regular page load.
// Accepts either 'ajax' or 'nojs'.
$form['method'] = array(
'#type' => 'value',
'#value' => arg(2) === 'ajax' ? 'ajax' : 'nojs',
);
$form['note'] = array(
'#type' => $text_processing == 'filtered_text' ? 'text_format' : 'textarea',
'#format' => $text_processing == 'filtered_text' ? $note->text_format : NULL,
'#prefix' => '<div id="textarea_' . $field['field_name'] . '" class="editor_note_field_wrapper">',
'#suffix' => '</div>',
'#title' => t('Update note'),
'#default_value' => $note->note,
'#description' => $field_instance['description'],
'#required' => TRUE,
'#rows' => $field['settings']['notes_size'],
'#resizable' => FALSE,
'#attributes' => array(
'maxlength' => $field['settings']['notes_maxlength'] > 0 ? $field['settings']['notes_maxlength'] : '',
'placeholder' => $field['settings']['notes_placeholder'],
),
);
$form['note_id'] = array(
'#type' => 'value',
'#value' => $note->id,
);
$form['note_entity_type'] = array(
'#type' => 'value',
'#value' => $note->entity_type,
);
$form['note_bundle'] = array(
'#type' => 'value',
'#value' => $note->bundle,
);
$form['note_entity_id'] = array(
'#type' => 'value',
'#value' => $note->entity_id,
);
$form['note_field_name'] = array(
'#type' => 'value',
'#value' => $note->field_name,
);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'element-inline',
'editor-note-actions',
),
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'editor_note_confirm_form_cancel',
),
);
$form['actions']['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#validate' => array(
'editor_note_confirm_edit_form_validate_update',
),
'#submit' => array(
'editor_note_confirm_edit_form_update',
),
);
if ($text_processing == 'filtered_text') {
$form['#attached']['css'][] = drupal_get_path('module', 'editor_note') . '/css/editor-note-text-format.css';
}
}
else {
$form['note'] = array(
'#markup' => '<p>' . t('Selected note cannot be loaded. Cancel action and reload the page to refresh notes widget.') . '</p>',
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'editor_note_confirm_form_cancel',
),
);
}
return $form;
}