[support] form not come into theme

bharani kumar bharanikumariyerphp at gmail.com
Wed Nov 5 17:00:40 UTC 2008


Hi Friends

Am preparing the hotel search ,

I did like when select the radio1 then form1 will display if selected the
radio2 then form 2 will display,


Here is the code

module and js code


module code below

<?php

$modpath = drupal_get_path('module','reservation');
drupal_add_js($modpath . '/reservation.js','module');

function reservation_menu() {

    //array
    $content[] ="";

    $content[] = array(
    'title' => t('Reservation'),
    'path' => 'node/reservation',
    'callback' => 'reservation_page',
    'access' => user_access('access content')
    );
    return $content;
}


    /**
    * called when user goes to example.com/?q=formexample
    */
function reservation_page() {

          $output = t('Search By');

      if(isset($_REQUEST['hdnSubmit'])==0){
      echo "HDN value is 0";
              //return the HTML generated form the $form data structure.
              $output .= drupal_get_form( 'reservation_form');
              $output .= drupal_get_form( 'address_form');
              //$output .= drupal_get_form( 'formAddress');
      }
      else{
              echo "HDN value is 1";
              $output .= drupal_get_form('formAddress');
            $output .= drupal_get_form('address_form');


      }
      return $output;

}

function reservation_form(){



    $form['city'] = array(
    '#id' =>'testcity',
     '#title' => t('Where'),
     '#type' => 'radios',
     '#description' => t(''),
     '#options' => array(t('City'),t('Address')),
     '#default_value' => variable_get('city', 0),
     '#required' => TRUE,
     '#attributes' => array('onclick' => "javascript:callform(this.value)"),
    );


    $form['txtWhere'] = array(
     '#title' => t('Where'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#required' => TRUE,
    );

    $form['txtChkIn'] = array(
     '#title' => t('Check-In'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#attributes' => array('class' => 'jscalendar'),
             '#jscalendar_ifFormat' => '%Y-%m-%d %H:%M',
             '#jscalendar_showsTime' => 'true',

    );

    $form['txtChkOut'] = array(
     '#title' => t('Check-Out'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#attributes' => array('class' => 'jscalendar'),
             '#jscalendar_ifFormat' => '%Y-%m-%d %H:%M',
             '#jscalendar_showsTime' => 'true',
    );

    $form['guest'] = array(
        '#type' => 'select',
        '#title' => t('Guests'),
        '#options' => array(
        1 => '1',
        2 => '2',
        3 => '3',
        4 => '4',
        5 => '5',
        ),
        '#default_value' => '1',
        '#description' => t(''),
        '#required' => TRUE
    );

    $form['rooms'] = array(
        '#type' => 'select',
        '#title' => t('Rooms'),
        '#options' => array(
        1 => '1',
        2 => '2',
        3 => '3',
        4 => '4',
        5 => '5',
        ),
        '#default_value' => '1',
        '#description' => t(''),
        '#required' => TRUE
    );

    $form['submit'] = array(
       '#type' => 'submit',
       '#value' => t('submit')
      );


    return $form;
}

function address_form(){
    echo "<div id='divform1' style='display:none;'>Form 1</div>";
    print "<div id='divform2'
style='display:none;'>".drupal_get_form('formAddress')."</div>";

}


function formAddress(){



    $form['address'] = array(
    '#id' =>'testcity',
     '#title' => t('Where'),
     '#type' => 'radios',
     '#description' => t(''),
     '#options' => array(t('City'),t('Address')),
     '#default_value' => variable_get('address', 1),
     '#required' => TRUE,
     '#attributes' => array('onclick' => "javascript:callform(this.value)"),
    );


    $form['txtAddress'] = array(
     '#title' => t('Address'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#required' => TRUE,
    );

    $form['txtCity'] = array(
     '#title' => t('City'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#required' => TRUE,
    );

    $form['txtPostalcode'] = array(
     '#title' => t('Postal Code'),
     '#type' => 'textfield',
     '#description' => t(''),
     );

    $form['txtNickname'] = array(
     '#title' => t('Nickname'),
     '#type' => 'textfield',
     '#description' => t(''),
     );

    $form['txtChkIn'] = array(
     '#title' => t('Check-In'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#attributes' => array('class' => 'jscalendar'),
             '#jscalendar_ifFormat' => '%Y-%m-%d %H:%M',
             '#jscalendar_showsTime' => 'true',

    );

    $form['txtChkOut'] = array(
     '#title' => t('Check-Out'),
     '#type' => 'textfield',
     '#description' => t(''),
     '#attributes' => array('class' => 'jscalendar'),
             '#jscalendar_ifFormat' => '%Y-%m-%d %H:%M',
             '#jscalendar_showsTime' => 'true',
    );

    $form['guest'] = array(
        '#type' => 'select',
        '#title' => t('Guests'),
        '#options' => array(
        1 => '1',
        2 => '2',
        3 => '3',
        4 => '4',
        5 => '5',
        ),
        '#default_value' => '1',
        '#description' => t(''),
        '#required' => TRUE
    );

    $form['rooms'] = array(
        '#type' => 'select',
        '#title' => t('Rooms'),
        '#options' => array(
        1 => '1',
        2 => '2',
        3 => '3',
        4 => '4',
        5 => '5',
        ),
        '#default_value' => '1',
        '#description' => t(''),
        '#required' => TRUE
    );

    $form['submit'] = array(
       '#type' => 'submit',
       '#value' => t('submit')
      );
       $form['hdnSubmit'] = array(
       '#type' => 'hidden',
       '#value' => '0'
      );

    return $form;

}


JS code below

// JavaScript Document
function callform(str){
    if(str==0){
        document.getElementById('divform1').style.display = 'none';
        document.getElementById('divform2').style.display = 'none';
        document.getElementById('reservation-form').style.display = 'block';


    }
    else{

        document.getElementById('divform1').style.display = 'none';
        document.getElementById('divform2').style.display = 'block';
        document.getElementById('reservation-form').style.display = 'none';
        document.getElementById('formAddress').style.display = 'block';
    }

}


Here my problem is,

When i select the city option then city search form will displayed inside
theme,

But i click the address option then formAddress form will displaying above
of the theme,

Any idea how to bring inside theme,


-- 
உங்கள் நண்பன்
பரணி  குமார்

Regards
B.S.Bharanikumar

POST YOUR OPINION
http://bharanikumariyer.hyperphp.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20081105/d5d36cd8/attachment-0001.htm 


More information about the support mailing list