/[drupal]/contributions/docs/developer/examples/multipage_form_example.module
ViewVC logotype

Diff of /contributions/docs/developer/examples/multipage_form_example.module

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

revision 1.8.2.2, Mon May 1 10:08:51 2006 UTC revision 1.11, Tue May 26 17:19:44 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  // $Id: multipage_form_example.module,v 1.8 2006/04/08 03:35:39 drumm Exp $  // $Id: multipage_form_example.module,v 1.10 2008/10/12 08:52:36 davereid Exp $
4    
5  /**  /**
6   * Implementation of hook_help().   * Implementation of hook_help().
# Line 68  function multipage_form_example_form(&$n Line 68  function multipage_form_example_form(&$n
68      '#values'        => array('n' => 'north', 'e' => 'east', 'w' => 'west', 's' => 'south', ),      '#values'        => array('n' => 'north', 'e' => 'east', 'w' => 'west', 's' => 'south', ),
69    );    );
70    
   
   
71    // Helper for our multipage - does field switching, sets options    // Helper for our multipage - does field switching, sets options
72    // based on validated $form_values instead of $_POST, and so forth.    // based on validated $form_values instead of $_POST, and so forth.
73    $form['#pre_render'] = array('multipage_form_example_pre_render');    $form['#pre_render'] = array('multipage_form_example_pre_render');
# Line 161  function theme_multipage_form_example_no Line 159  function theme_multipage_form_example_no
159    $content = '';    $content = '';
160    
161    if (in_array($form['page']['#value'], array(3,4))) {    if (in_array($form['page']['#value'], array(3,4))) {
162      $content .= '<p>'. t('Your favorite person is %person, and they %like gummi bears.', array('%person' => check_plain($form['person']['fav_person']['#value']), '%like' => ($form['person']['fav_gummi']['#value'] ? t('like') : t('don\'t like')))) .'</p>';      $content .= '<p>' . t('Your favorite person is %person, and they %like gummi bears.', array('%person' => check_plain($form['person']['fav_person']['#value']), '%like' => ($form['person']['fav_gummi']['#value'] ? t('like') : t('don\'t like')))) . '</p>';
163    }    }
164    
165    if (in_array($form['page']['#value'], array(4))) {    if (in_array($form['page']['#value'], array(4))) {
166      $content .= '<p>'. t('Your favorite color is %color, and your favorite number is %number.', array('%color' => check_plain($form['fav_color']['#value']), '%number' => check_plain($form['fav_number']['#value'])));      $content .= '<p>' . t('Your favorite color is %color, and your favorite number is %number.', array('%color' => check_plain($form['fav_color']['#value']), '%number' => check_plain($form['fav_number']['#value'])));
167    }    }
168    
169    foreach (element_children($form) as $key) {    foreach (element_children($form) as $key) {
# Line 299  function multipage_form_example_custom_s Line 297  function multipage_form_example_custom_s
297      $nid = db_result(db_query("SELECT id FROM {sequences} WHERE name = 'node_nid'"));      $nid = db_result(db_query("SELECT id FROM {sequences} WHERE name = 'node_nid'"));
298    }    }
299    
300    variable_set('multipage_form_example_'. $nid, $array);    variable_set('multipage_form_example_' . $nid, $array);
301  }  }
302    
303  /**  /**
# Line 310  function multipage_form_example_custom_s Line 308  function multipage_form_example_custom_s
308   * every time a node is loaded, and allows us to do some loading of our own.   * every time a node is loaded, and allows us to do some loading of our own.
309   */   */
310  function multipage_form_example_load($node) {  function multipage_form_example_load($node) {
311    $additions = variable_get('multipage_form_example_'. $node->nid, NULL);    $additions = variable_get('multipage_form_example_' . $node->nid, NULL);
312    $additions = (object) $additions;    $additions = (object) $additions;
313    return $additions;    return $additions;
314  }  }
# Line 322  function multipage_form_example_load($no Line 320  function multipage_form_example_load($no
320   */   */
321  function multipage_form_example_delete($node) {  function multipage_form_example_delete($node) {
322    // Notice that we're matching all revision, by using the node's nid.    // Notice that we're matching all revision, by using the node's nid.
323    variable_del('multipage_form_example_'. $node->nid);    variable_del('multipage_form_example_' . $node->nid);
324  }  }
325    
326  /**  /**
# Line 432  function multipage_form_set_element_visi Line 430  function multipage_form_set_element_visi
430   *   The new value for the attribute.   *   The new value for the attribute.
431   */   */
432  function multipage_form_set_attribute(&$element, $key, $new_value) {  function multipage_form_set_attribute(&$element, $key, $new_value) {
433    $element['#multipage_form_original_'. $key] = $element[$key];    $element['#multipage_form_original_' . $key] = $element[$key];
434    $element[$key] = $new_value;    $element[$key] = $new_value;
435  }  }
436    
# Line 455  function multipage_form_restore_attribut Line 453  function multipage_form_restore_attribut
453   * element   * element
454   */   */
455  function multipage_form_example_elements() {  function multipage_form_example_elements() {
456     $type['hidden_array'] = array('#input' => TRUE, '#process' => array('expand_hidden_array' => array()), '#tree' => TRUE);    $type['hidden_array'] = array('#input' => TRUE, '#process' => array('expand_hidden_array' => array()), '#tree' => TRUE);
457     return $type;    return $type;
458  }  }
459    
460  function expand_hidden_array($element) {  function expand_hidden_array($element) {

Legend:
Removed from v.1.8.2.2  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.2