1 backup.inc | backup_settings_form_submit(array $form, array &$form_state) |
Helper submit function for creating a backup.
This is intended to help execute a backup as configured by backup_settings_form(). To add this submit handler to a custom form, it is recommended to add this to the form #submit property, such as:
<?php
$form['#submit'] = array(
'backup_settings_form_submit',
'my_module_settings_form_submit,
);
?>
Parameters
array $form: The form array, as created by backdrop_settings_form().
array $form_state: The form state, containing $form_state['values']['targets'] and optionally $form_state['values']['options'].
Return value
void:
See also
File
- core/
includes/ backup.inc, line 245 - Contains functionality related to creating and restoring site backups.
Code
function backup_settings_form_submit(array $form, array &$form_state) {
$backup_targets = $form_state['values']['targets'];
$options = $form_state['values']['options'] ? : array();
$errors = array();
$ready = backup_batch_prepare($backup_targets, $options, $errors);
if ($ready) {
backup_batch($backup_targets, $options);
}
else {
foreach ($errors as $error) {
backdrop_set_message($error, 'error');
}
}
}