Mercurial > defr > drupal > core
comparison includes/form.inc @ 15:4347c45bb494 6.7
Drupal 6.7
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:32:44 +0100 |
parents | 8b6c45761e01 |
children | 3edae6ecd6c6 |
comparison
equal
deleted
inserted
replaced
14:626fcabfa4b8 | 15:4347c45bb494 |
---|---|
1 <?php | 1 <?php |
2 // $Id: form.inc,v 1.265.2.13 2008/10/16 12:43:08 goba Exp $ | 2 // $Id: form.inc,v 1.265.2.16 2008/11/22 13:03:19 dries Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @defgroup forms Form builder functions | 5 * @defgroup forms Form builder functions |
6 * @{ | 6 * @{ |
7 * Functions that build an abstract representation of a HTML form. | 7 * Functions that build an abstract representation of a HTML form. |
587 * A unique string identifying the form for validation, submission, | 587 * A unique string identifying the form for validation, submission, |
588 * theming, and hook_form_alter functions. | 588 * theming, and hook_form_alter functions. |
589 * @param $form | 589 * @param $form |
590 * An associative array containing the structure of the form. | 590 * An associative array containing the structure of the form. |
591 * @return | 591 * @return |
592 * A string containing the path of the page to display when processing | 592 * A string containing the themed HTML. |
593 * is complete. | |
594 */ | 593 */ |
595 function drupal_render_form($form_id, &$form) { | 594 function drupal_render_form($form_id, &$form) { |
596 // Don't override #theme if someone already set it. | 595 // Don't override #theme if someone already set it. |
597 if (!isset($form['#theme'])) { | 596 if (!isset($form['#theme'])) { |
598 init_theme(); | 597 init_theme(); |
1497 * A themed HTML string representing the form item group. | 1496 * A themed HTML string representing the form item group. |
1498 * | 1497 * |
1499 * @ingroup themeable | 1498 * @ingroup themeable |
1500 */ | 1499 */ |
1501 function theme_fieldset($element) { | 1500 function theme_fieldset($element) { |
1502 if ($element['#collapsible']) { | 1501 if (!empty($element['#collapsible'])) { |
1503 drupal_add_js('misc/collapse.js'); | 1502 drupal_add_js('misc/collapse.js'); |
1504 | 1503 |
1505 if (!isset($element['#attributes']['class'])) { | 1504 if (!isset($element['#attributes']['class'])) { |
1506 $element['#attributes']['class'] = ''; | 1505 $element['#attributes']['class'] = ''; |
1507 } | 1506 } |
1508 | 1507 |
1509 $element['#attributes']['class'] .= ' collapsible'; | 1508 $element['#attributes']['class'] .= ' collapsible'; |
1510 if ($element['#collapsed']) { | 1509 if (!empty($element['#collapsed'])) { |
1511 $element['#attributes']['class'] .= ' collapsed'; | 1510 $element['#attributes']['class'] .= ' collapsed'; |
1512 } | 1511 } |
1513 } | 1512 } |
1514 | 1513 |
1515 return '<fieldset'. drupal_attributes($element['#attributes']) .'>'. ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . (isset($element['#value']) ? $element['#value'] : '') ."</fieldset>\n"; | 1514 return '<fieldset'. drupal_attributes($element['#attributes']) .'>'. ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . (isset($element['#value']) ? $element['#value'] : '') ."</fieldset>\n"; |
1913 if (!isset($element['#default_value']) || $element['#default_value'] == 0) { | 1912 if (!isset($element['#default_value']) || $element['#default_value'] == 0) { |
1914 $element['#default_value'] = array(); | 1913 $element['#default_value'] = array(); |
1915 } | 1914 } |
1916 foreach ($element['#options'] as $key => $choice) { | 1915 foreach ($element['#options'] as $key => $choice) { |
1917 if (!isset($element[$key])) { | 1916 if (!isset($element[$key])) { |
1918 $element[$key] = array('#type' => 'checkbox', '#processed' => TRUE, '#title' => $choice, '#return_value' => $key, '#default_value' => isset($value[$key]), '#attributes' => $element['#attributes']); | 1917 $element[$key] = array( |
1918 '#type' => 'checkbox', | |
1919 '#processed' => TRUE, | |
1920 '#title' => $choice, | |
1921 '#return_value' => $key, | |
1922 '#default_value' => isset($value[$key]), | |
1923 '#attributes' => $element['#attributes'], | |
1924 '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL, | |
1925 ); | |
1919 } | 1926 } |
1920 } | 1927 } |
1921 } | 1928 } |
1922 return $element; | 1929 return $element; |
1923 } | 1930 } |