Subversion Repositories Applications.papyrus

Rev

Rev 320 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 320 Rev 443
Line 15... Line 15...
15
// +----------------------------------------------------------------------+
15
// +----------------------------------------------------------------------+
16
// | Authors: Adam Daniel <adaniel1@eesus.jnj.com>                        |
16
// | Authors: Adam Daniel <adaniel1@eesus.jnj.com>                        |
17
// |          Bertrand Mansion <bmansion@mamasam.com>                     |
17
// |          Bertrand Mansion <bmansion@mamasam.com>                     |
18
// +----------------------------------------------------------------------+
18
// +----------------------------------------------------------------------+
19
//
19
//
20
// $Id: select.php,v 1.1 2005-03-30 08:50:33 jpm Exp $
20
// $Id: select.php,v 1.2 2005-09-20 17:01:22 ddelon Exp $
Line 21... Line 21...
21
 
21
 
Line 22... Line 22...
22
require_once('HTML/QuickForm/element.php');
22
require_once('HTML/QuickForm/element.php');
23
 
23
 
Line 444... Line 444...
444
                return $this->loadArray($options, $param1);
444
                return $this->loadArray($options, $param1);
445
                break;
445
                break;
446
            case (is_a($options, 'db_result')):
446
            case (is_a($options, 'db_result')):
447
                return $this->loadDbResult($options, $param1, $param2, $param3);
447
                return $this->loadDbResult($options, $param1, $param2, $param3);
448
                break;
448
                break;
449
            case (is_string($options) && !empty($options) || is_subclass_of($options, "db_common")):
449
            case (is_string($options) && !empty($options) ):
450
                return $this->loadQuery($options, $param1, $param2, $param3, $param4);
450
                return $this->loadQuery($options, $param1, $param2, $param3, $param4);
451
                break;
451
                break;
452
        }
452
        }
453
    } // end func load
453
    } // end func load
Line 510... Line 510...
510
    {
510
    {
511
        $value = array();
511
        $value = array();
512
        if (is_array($this->_values)) {
512
        if (is_array($this->_values)) {
513
            foreach ($this->_values as $key => $val) {
513
            foreach ($this->_values as $key => $val) {
514
                for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
514
                for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
515
                    if ($val == $this->_options[$i]['attr']['value']) {
515
                    if ((string)$val == (string)$this->_options[$i]['attr']['value']) {
516
                        $value[$key] = $this->_options[$i]['text'];
516
                        $value[$key] = $this->_options[$i]['text'];
517
                        break;
517
                        break;
518
                    }
518
                    }
519
                }
519
                }
520
            }
520
            }
Line 523... Line 523...
523
        if ($this->_persistantFreeze) {
523
        if ($this->_persistantFreeze) {
524
            $name = $this->getPrivateName();
524
            $name = $this->getPrivateName();
525
            // Only use id attribute if doing single hidden input
525
            // Only use id attribute if doing single hidden input
526
            if (1 == count($value)) {
526
            if (1 == count($value)) {
527
                $id     = $this->getAttribute('id');
527
                $id     = $this->getAttribute('id');
528
                $idAttr = isset($id)? ' id="' . $id . '"': '';
528
                $idAttr = isset($id)? array('id' => $id): array();
529
            } else {
529
            } else {
530
                $idAttr = '';
530
                $idAttr = array();
531
            }
531
            }
532
            foreach ($value as $key => $item) {
532
            foreach ($value as $key => $item) {
533
                $html .= '<input type="hidden"' . $idAttr . ' name="' . 
533
                $html .= '<input' . $this->_getAttrString(array(
-
 
534
                             'type'  => 'hidden',
-
 
535
                             'name'  => $name,
534
                    $name . '" value="' . $this->_values[$key] . '" />';
536
                             'value' => $this->_values[$key]
-
 
537
                         ) + $idAttr) . ' />';
535
            }
538
            }
536
        }
539
        }
537
        return $html;
540
        return $html;
538
    } //end func getFrozenHtml
541
    } //end func getFrozenHtml
Line 571... Line 574...
571
            return $this->_prepareValue($cleanValue, $assoc);
574
            return $this->_prepareValue($cleanValue, $assoc);
572
        }
575
        }
573
    }
576
    }
Line 574... Line 577...
574
    
577
    
-
 
578
    // }}}
-
 
579
    // {{{ onQuickFormEvent()
-
 
580
 
-
 
581
    function onQuickFormEvent($event, $arg, &$caller)
-
 
582
    {
-
 
583
        if ('updateValue' == $event) {
-
 
584
            $value = $this->_findValue($caller->_constantValues);
-
 
585
            if (null === $value) {
-
 
586
                $value = $this->_findValue($caller->_submitValues);
-
 
587
                // Fix for bug #4465
-
 
588
                // XXX: should we push this to element::onQuickFormEvent()?
-
 
589
                if (null === $value && !$caller->isSubmitted()) {
-
 
590
                    $value = $this->_findValue($caller->_defaultValues);
-
 
591
                }
-
 
592
            }
-
 
593
            if (null !== $value) {
-
 
594
                $this->setValue($value);
-
 
595
            }
-
 
596
            return true;
-
 
597
        } else {
-
 
598
            return parent::onQuickFormEvent($event, $arg, $caller);
-
 
599
        }
-
 
600
    }
-
 
601
 
575
    // }}}
602
    // }}}
576
} //end class HTML_QuickForm_select
603
} //end class HTML_QuickForm_select