Active
Project:
Block Save and Edit Buttons
Version:
6.x-1.x-dev
Component:
Documentation
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Nov 2014 at 17:03 UTC
Updated:
12 Nov 2014 at 17:03 UTC
If you are looking for a way to stay on the edit form of a block after you click save because you are tired of being redirected to the blocks listings page, this module is for you. Well at least it's code. The module is not maintained anymore but it's code it very simple.
If you know how to read a patch manually, you can grab the code for Drupal 7 here #1528656: Make compatible for D7.
I did not find this module on Google that's why I created this issue with this title.
You know what, I'm just gonna copy paste the code, it'll make it even easier!
<?php
function block_save_edit_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
// Catch the block add form
case 'block_add_block_form':
case 'block_admin_configure':
// Add the new button at the end of the form
// Catch the submit with our own function
$form['actions']['apply'] = array(
'#type' => 'submit',
'#value' => t('Save and edit'),
'#submit' => $form['#submit'],
);
$form['actions']['apply']['#submit'][] = 'block_save_edit_form_submit';
break;
default:
break;
}
}
function block_save_edit_form_submit($form, &$form_state) {
// Force update of the blocks table.
// This normally happens at the block list page, which we'll skip
_block_rehash();
// Redirect to the block configure page for the just-created block
$form_state['redirect'] = 'admin/structure/block/manage/'. $form_state['values']['module'] .'/'. $form_state['values']['delta'] .'/configure';
}
?>