Richiamare una pagina/form attraverso l'hook_menu
Questo modulo mi funziona ma solo se vado alla pagina
rep_locator/ajax_example_simplest.
Come faccio a farlo funzionare anche nella rep_locator ?
<?php
/**
* @file
* Install, update and uninstall functions for the rep_locator.
*/
// $Id$
/**
* Implements hook_help().
*/
function rep_locator_help($section='') {
$output = '';
switch ($section) {
case "admin/help#rep_locator":
$output .= t('help_admin');
break;
}
return $output;
} // function rep_locator_help
/**
* Implements hook_permission().
*/
function rep_locator_permission() {
return array(
'access rep_locator content' => array(
'title' => t('content Title'),
'description' => t('content Description')
)
);
} // function rep_locator_permission()
/**
* Implements hook_menu().
*/
function rep_locator_menu() {
$items['rep_locator'] = array(
'title' => 'List Your Business',
'page callback' => 'drupal_get_form',
'page arguments' => array('rep_locator_page'),
'access callback' => TRUE,
);
$items['rep_locator/ajax_example_simplest'] = array(
'title' => 'ajax_example_simplest',
'page callback' => 'drupal_get_form',
'page arguments' => array('ajax_example_autotextfields'),
'access callback' => TRUE,
'weight' => 0,
);
return $items;
} // function rep_locator_menu()
/**
* Implements hook_page().
*/
function rep_locator_page() {
return drupal_get_form('ajax_example_autotextfields');
}
/**
* @ingroup ajax_examples
* @{
*/
/**
* Show/hide textfields based on AJAX-enabled checkbox clicks.
*/
function ajax_example_autotextfields($form, &$form_state) {
$form['rep_sector'] = array(
'#type' => 'select',
'#id' => 'rep_sector',
'#name' => 'rep_sector',
'#size' => 1,
'#options' => array('1' => '1', '2' => '2', '3' => '3'),
'#ajax' => array(
'callback' => 'ajax_example_autotextfields_callback',
'wrapper' => 'second_select',
'effect' => 'fade',
)
);
$form['second_select'] = array(
'#prefix' => '<div id="second_select">',
'#suffix' => '</div>',
'#type' => 'fieldset',
);
// Since checkboxes return TRUE or FALSE, we have to check that
// $form_state has been filled as well as what it contains.
if (!empty($form_state['values']['rep_sector']) && $form_state['values']['rep_sector']!='2') {
$form['second_select']['rep_state'] = array(
'#type' => 'select',
'#id' => 'rep_state',
'#name' => 'rep_state',
'#size' => 1,
'#options' => array('1' => '1', '2' => '2', '3' => '3'),
);
}
return $form;
}
/**
* Selects the piece of the form we want to use as replacement text and returns
* it as a form (renderable array).
*
* @return renderable array (the textfields element)
*/
function ajax_example_autotextfields_callback($form, $form_state) {
return $form['second_select'];
}
Risposte
Prova a modificare nella
Prova a modificare nella funzione rep_locator_menu l'elemento
<?php
$items['rep_locator'] = array(
'title' => 'List Your Business',
'page callback' => 'drupal_get_form',
'page arguments' => array('rep_locator_page'),
'access callback' => TRUE,
);
?>
così:
<?php
$items['rep_locator'] = array(
'title' => 'List Your Business',
'page callback' => 'rep_locator_page',
'access callback' => TRUE,
);
?>
Grazie, risolto con /***
Grazie, risolto con
/**
* Implements hook_menu().
*/
function rep_locator_menu() {
$items['rep_locator'] = array(
'title' => 'List Your Business',
'page callback' => 'rep_locator_page',
'page arguments' => array('ajax_rep_locator_form'),
'access callback' => TRUE,
);
return $items;
} // function rep_locator_menu()
Bene, ma puoi anche eliminare
Bene, ma puoi anche eliminare il frammento
<?php
'page arguments' => array('ajax_rep_locator_form'),
?>
perchè la funzione rep_locator_page non accetta argomenti.
Ciao.