1 filter.pages.inc | filter_format_editor_dialog_save($form, &$form_state) |
Form AJAX callback. Sends the save editor AJAX command and closes the dialog.
See also
filter_format_editor_link_form()
filter_format_editor_image_form()
File
- core/
modules/ filter/ filter.pages.inc, line 494 - User page callbacks for the Filter module.
Code
function filter_format_editor_dialog_save($form, &$form_state) {
$dialog_selector = '#backdrop-dialog';
if (isset($form_state['storage']['dialog_selector'])) {
$dialog_selector = $form_state['storage']['dialog_selector'];
}
$commands = array();
$errors = form_get_errors();
if (!empty($errors)) {
$error_messages = theme('status_messages');
$rendered_form = backdrop_render($form);
$commands[] = ajax_command_remove('.editor-dialog .messages');
$commands[] = ajax_command_replace('.editor-dialog form.filter-format-editor-image-form', $rendered_form);
$commands[] = ajax_command_prepend('.editor-dialog .ui-dialog-content', $error_messages);
// Check whether this is an image upload, a library selection, or a link to
// another non-library file. Note that classes "first" and "last" are
// dynamically assigned, so are not consistently on the same link.
if (empty($form_state['input']['fid']['fid'])) {
// Custom link to a non-library file.
$commands[] = ajax_command_invoke('.editor-dialog form.filter-format-editor-image-form a.last', 'click');
}
else {
// Library file has been selected.
$commands[] = ajax_command_invoke('.editor-dialog form.filter-format-editor-image-form a.first', 'click');
}
}
else {
$commands[] = array(
'command' => 'editorDialogSave',
'values' => $form_state['values'],
);
$commands[] = ajax_command_close_dialog($dialog_selector);
}
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}