By najubudeen on
hi, i try to add a parameter to admin/config/my_page/my_menu. the page url should be admin/config/my_page/my_menu?get_option=yes like this.
my hoo_menu looks like this,
function my_modul_menu(){
$items = array();
$items['admin/config/my_page'] = array(
'title' => t('some title'),
'description' => t('some description'),
'position' => 'left',
'weight' => -30,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('page permission'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/my_page/my_menu'] = array(
'title' => 'some title',
'description' => t('some desc.'),
'page callback' => 'my_page_func',
'access arguments' => array('page permission'),
'weight' => -10,
);
return $items;
}
function my_page_func(){
$output = '';
if($_GET['get_option'] == 'yes'){
// do something here
}else{
$output .= drupal_render(drupal_get_form('my_form'));
}
return $output;
}
function my_form($form,&$form_state){
$form_state['redirect'] = 'admin/config/my_page/my_menu?get_option=yes';
$form['#submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}
how do i do that? please help someone?
Comments
In Drupal there is no need to
In Drupal there is no need to pass parameter like this. hook_menu() gives you a simple way to pass arguments in URL.
Your code should be something like this.
You can take more idea about this from here.
Pushpinder Rana #pushpinderdrupal
Acquia Certified Drupal Expert
hi pushpinderrana, i tested
hi pushpinderrana, i tested your codes. but it doesn't display menu at the configuration page. i have written my codes below.
There is a chance of some
There is a chance of some TYPO mistake, for menu you need to define parent call back function in correct manner. It should be something like this.
Also following code is not looking fine as you have added redirect option in form without any other fields. I believe you are not sharing your complete code with us so it is looking like this.
Pushpinder Rana #pushpinderdrupal
Acquia Certified Drupal Expert
hi pushpinderrana, i have
hi pushpinderrana, i have rectified my codes. it works correctly now. Thank you very much for your reply.