/[drupal]/contributions/modules/ahah_helper/ahah_helper_demo.module
ViewVC logotype

Diff of /contributions/modules/ahah_helper/ahah_helper_demo.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Wed Nov 19 16:25:29 2008 UTC revision 1.3, Thu Nov 20 01:20:34 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: ahah_helper_demo.module,v 1.1 2008/08/29 18:58:21 wimleers Exp $  // $Id: ahah_helper_demo.module,v 1.2 2008/11/19 16:25:29 wimleers Exp $
3    
4    
5  //----------------------------------------------------------------------------  //----------------------------------------------------------------------------
# Line 31  function ahah_helper_demo_form($form_sta Line 31  function ahah_helper_demo_form($form_sta
31    
32    ahah_helper_register($form, $form_state);    ahah_helper_register($form, $form_state);
33    
34      // We remember the last company used, to restore it when a user switched to
35      // Personal usage and back to Company usage.
36      if (isset($form_state['values']['billing_info']['company_name'])) {
37        $form_state['storage']['billing_info']['company_name'] = $form_state['values']['billing_info']['company_name'];
38      }
39    
40    $form['billing_info'] = array(    $form['billing_info'] = array(
41      '#type' => 'fieldset',      '#type' => 'fieldset',
42      '#title' => t('Billing information'),      '#title' => t('Billing information'),
# Line 45  function ahah_helper_demo_form($form_sta Line 51  function ahah_helper_demo_form($form_sta
51        'private'  => t('Private'),        'private'  => t('Private'),
52        'company'  => t('Company'),        'company'  => t('Company'),
53      ),      ),
54      '#default_value' => $form_state['values']['billing_info']['usage'],      '#default_value' => 'company',
55      '#ahah' => array(      '#ahah' => array(
56        'event' => 'change',        'event' => 'change',
57        // This is the "magical path". Note that the parameter is an array of        // This is the "magical path". Note that the parameter is an array of
# Line 68  function ahah_helper_demo_form($form_sta Line 74  function ahah_helper_demo_form($form_sta
74    
75    
76    // If 'company' is selected, then these two form items will be displayed.    // If 'company' is selected, then these two form items will be displayed.
77    if ($form_state['values']['billing_info']['usage'] == 'company') {    if (!isset($form_state['values']) || $form_state['values']['billing_info']['usage'] == 'company') {
78      $form['billing_info']['company_name'] = array(      $form['billing_info']['company_name'] = array(
79        '#type' => 'textfield',        '#type' => 'textfield',
80        '#title' => t('Company name'),        '#title' => t('Company name'),
81        '#required' => TRUE,        '#required' => TRUE,
82        '#size' => 20,        '#size' => 20,
83        '#maxlength' => 255,        '#maxlength' => 255,
84        '#default_value' => $form_state['values']['billing_info']['company_name'],        // If the user switched to Private usage and back to Company usage, we
85          // remembered his company's name!
86          '#default_value' => (isset($form_state['storage']['billing_info']['company_name'])) ? $form_state['storage']['billing_info']['company_name'] : '',
87      );      );
88      $form['billing_info']['vat'] = array(      $form['billing_info']['vat'] = array(
89        '#type' => 'textfield',        '#type' => 'textfield',
# Line 83  function ahah_helper_demo_form($form_sta Line 91  function ahah_helper_demo_form($form_sta
91        '#description' => t('Please enter a Belgian VAT number, the format is: <em>BE0999999999</em>.'),        '#description' => t('Please enter a Belgian VAT number, the format is: <em>BE0999999999</em>.'),
92        '#size' => 20,        '#size' => 20,
93        '#maxlength' => 255,        '#maxlength' => 255,
       '#default_value' => $form_state['values']['billing_info']['vat'],  
94        '#ahah' => array(        '#ahah' => array(
95          'event' => 'blur',          'event' => 'blur',
96          'path' => ahah_helper_path(array('billing_info', 'vat')),          'path' => ahah_helper_path(array('billing_info', 'vat')),
# Line 104  function ahah_helper_demo_form($form_sta Line 111  function ahah_helper_demo_form($form_sta
111        '#required' => TRUE,        '#required' => TRUE,
112        '#size' => 20,        '#size' => 20,
113        '#maxlength' => 255,        '#maxlength' => 255,
       '#default_value' => $form_state['values']['billing_info']['first_name'],  
114      );      );
115      $form['billing_info']['last_name'] = array(      $form['billing_info']['last_name'] = array(
116        '#type' => 'textfield',        '#type' => 'textfield',
# Line 112  function ahah_helper_demo_form($form_sta Line 118  function ahah_helper_demo_form($form_sta
118        '#required' => TRUE,        '#required' => TRUE,
119        '#size' => 20,        '#size' => 20,
120        '#maxlength' => 255,        '#maxlength' => 255,
       '#default_value' => $form_state['values']['billing_info']['last_name'],  
121      );      );
122    }    }
123    
# Line 122  function ahah_helper_demo_form($form_sta Line 127  function ahah_helper_demo_form($form_sta
127      '#required' => TRUE,      '#required' => TRUE,
128      '#size' => 20,      '#size' => 20,
129      '#maxlength' => 255,      '#maxlength' => 255,
     '#default_value' => $form_state['values']['billing_info']['address'],  
130    );    );
131    $form['billing_info']['country'] = array(    $form['billing_info']['country'] = array(
132      '#type' => 'textfield',      '#type' => 'textfield',
133      '#title' => t('Country'),      '#title' => t('Country'),
134      '#size' => 20,      '#size' => 20,
135      '#maxlength' => 255,      '#maxlength' => 255,
     '#default_value' => $form_state['values']['billing_info']['country'],  
136    );    );
137    
138    $form['save'] = array(    $form['save'] = array(

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2