commit ea9cd342683e9aa4dff80634ace529e4f9fc5087 Author: brantwynn Date: Sun May 19 19:21:10 2013 -0700 1998582-new_changes diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 74e093d..fd169d7 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -1821,17 +1821,24 @@ function views_cache_get($cid, $use_language = FALSE) { /** * Implement hook_form_alter for the views block form. * - * Views sets up its own plugin portions of the block configuration form but - * assigning machine names is not handled by the plugin so we do this here. + * Views overrides block configuration form elements during ViewsBlock:form() + * but machine_name assignment is added later by BlockFormController:form() + * so we provide an override for the block machine_name here. */ function views_form_block_form_alter(&$form, &$form_state) { + // Ensure the block-form being altered is a Views block configuration form. if ($form['settings']['module']['#value'] == 'views') { + // Unset the machine_name provided by BlockFormController + unset($form['machine_name']['#machine_name']['source']); + // Load the Views plugin object using form_state array and create a + // block machine_name based on the View ID and View Display ID. $block_plugin = $form_state['build_info']['callback_object']->getEntity()->getPlugin(); list($plugin, $delta) = explode(':', $block_plugin->getPluginId()); - list($name, $displayID) = explode('-', $delta, 2); - unset($form['machine_name']['#machine_name']['source']); - $form['machine_name']['#default_value'] = 'views_block__' . $name . '_' . $displayID; + list($view_id, $display_id) = explode('-', $delta, 2); + // Override the Views block's machine_name by providing a default_value. + $form['machine_name']['#default_value'] = 'views_block__' . $view_id . '_' . $display_id; + // Prevent users from changing the auto-generate block machine_name. $form['machine_name']['#access'] = FALSE; - } + } }