Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ffield_menu(){
- // Модальное окно
- $items['ffield/%ctools_js/select'] = array(
- 'title' => 'Select',
- 'page callback' => 'ffield_select_callback',
- 'page arguments' => array(1),
- 'access arguments' => array('access content'),
- 'delivery callback' => 'ajax_deliver',
- 'theme callback' => 'ajax_base_page_theme',
- );
- // Следующая страница
- $items['ffield/%ctools_js/list/%id'] = array(
- 'title' => 'List',
- 'page callback' => 'ffield_list_callback',
- 'page arguments' => array(1, 2),
- 'access arguments' => array('access content'),
- 'delivery callback' => 'ajax_deliver',
- //'theme callback' => 'ajax_base_page_theme',
- );
- return $items;
- }
- function ffield_select_callback($js = NULL) {
- if ($js) {
- ctools_include('modal');
- $form_state = array(
- 'title' => t('Выберите адрес'),
- 'ajax' => TRUE,
- 'build_info' => array(
- 'args' => array(),
- ),
- );
- form_load_include($form_state, 'inc', 'ffield', 'select_add.pages');
- $commands = array();
- $commands = ctools_modal_form_wrapper('select_form', $form_state);
- return array('#type' => 'ajax', '#commands' => $commands);
- }
- }
- function ffield_list_callback($js = NULL, $id = NULL){
- //dd('this');
- if ($js){
- ctools_include('ajax');
- $q = db_select('ffield_AS_ADDROBJ', 'faddr')
- ->fields('faddr', array('id', 'AOGUID', 'PARENTGUID', 'FORMALNAME', 'SHORTNAME'))
- ->condition('PARENTGUID', $id, '=')
- ->orderBy('FORMALNAME', 'ASC')
- ->execute()
- ->fetchAll();
- }
- }
- // Форма которая выводится в модальном окне
- function select_form($form, &$form_state) {
- //....
- ctools_include('ajax');
- $form['link-' . $obj->id] = array(
- '#type' => 'link',
- '#href' => 'ffield/nojs/' . $obj->AOGUID,
- '#title' => $obj->FORMALNAME . ' ' . $obj->SHORTNAME . '.',
- '#attributes' => array(
- 'class' => array('ctools-use-ajax'),
- ),
- );
- // ....
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment