/** * Implements hook_form_alter(). */ function vbo_redirect_option_form_alter(&$form, &$form_state, $form_id) { // VBOの処理かのチェック if( isset($form_state['id']) && $form_state['id'] === "views_bulk_operations"){ // ここで、画面遷移先の保存処理は少し反則 // vbo_settingsに画面遷移先の追加は難しい(クラス構造体内にあるため) // 環境変数に画面遷移先(uri)を保存 if( isset($form_state['input']['options']['vbo_settings'][vbo_redirect_url]) ){ variable_set( 'vbo_redirect_url', $form_state['input']['options']['vbo_settings'][vbo_redirect_url] ) ; } // 画面遷移先のテキストフィールドを追加 $form['options']['vbo_settings']['vbo_redirect_url'] = array( '#type' => 'textfield', '#title' => t('Page to direct to after completion of batch'), '#description' => t('Redirects to the view when finished the operation'), '#default_value' => variable_get('vbo_redirect_url'), ); } }
/** * Implements hook_views_bulk_operations_form_alter(). */ function vbo_redirect_option_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) { $vbo_redirect_url = trim( variable_get('vbo_redirect_url') ) ; if( isset($vbo_redirect_url) && strlen($vbo_redirect_url) >0 ){ // check if vbo operation skip confirmation $skip_confirmation = false ; foreach( $vbo->options['vbo_operations'] as $key => $operation ){ if( $operation['selected'] && $operation['skip_confirmation'] ){ if( isset($form['select'][$key]) ) { $form['select'][$key]['#submit'][] = 'vbo_redirect_after_operation'; $skip_confirmation = true ; } } } // set redirect method when vbo has confirmation step if( !$skip_confirmation ){ $form['actions']['submit']['#submit'][] = 'vbo_redirect_after_operation' ; } } } // callback function to set redirect url function vbo_redirect_after_operation($form, &$form_state){ $vbo_redirect_url = trim( variable_get('vbo_redirect_url') ) ; $form_state['redirect'] = $vbo_redirect_url; }
添付 | サイズ |
---|---|
vbo_redirect_option.zip (1.19 KB) | 1.19 KB |