Example #1
0
 /**
  * Return label
  *
  * If no label is present, returns the currently set name.
  *
  * If a translator is present, returns the translated label.
  *
  * @return string
  */
 public function getLabel()
 {
     $value = parent::getLabel();
     if (null === $value) {
         $value = $this->getName();
     }
     if (null !== ($translator = $this->getTranslator())) {
         return $translator->translate($value);
     }
     return $value;
 }
 /**
  * Set value
  *
  * If value matches checked value, sets to that value, and sets the checked
  * flag to true.
  *
  * Any other value causes the unchecked value to be set as the current
  * value, and the checked flag to be set as false.
  *
  *
  * @param  mixed $value
  * @return Zend_Form_Element_Checkbox
  */
 public function setValue($value)
 {
     if ($value == $this->getCheckedValue()) {
         parent::setValue($value);
         $this->checked = true;
     } else {
         parent::setValue($this->getUncheckedValue());
         $this->checked = false;
     }
     return $this;
 }
Example #3
0
 /**
  * Is the value provided valid?
  *
  * Autoregisters InArray validator if necessary.
  *
  * @param  string $value
  * @param  mixed $context
  * @return bool
  */
 public function isValid($value, $context = null)
 {
     if ($this->registerInArrayValidator()) {
         if (!$this->getValidator('InArray')) {
             $options = $this->getMultiOptions();
             $this->addValidator('InArray', true, array(array_keys($options)));
         }
     }
     return parent::isValid($value, $context);
 }
 /**
  * __call
  *
  * @param  string $name  Method name
  * @param  array $arguments Arguments
  * @return mixed
  */
 public function __call($method, array $args)
 {
     $action = substr($method, 0, 3);
     $attribute = lcfirst(substr($method, 3));
     switch ($action) {
         case 'get':
             if (!$this->hasDijitParam(lcfirst($attribute))) {
                 return false;
             }
             return $this->getDijitParam(lcfirst($attribute));
             break;
         case 'set':
             $this->setDijitParam(lcfirst($attribute), $args[0]);
             return $this;
             break;
         default:
             if ($return = parent::__call($method, $args)) {
                 return $return;
             }
             break;
     }
 }
Example #5
0
 /**
  * Render
  *
  * Ensure that options property is set when rendering.
  * 
  * @param  Zend_View_Interface $view 
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     $this->options = array('checked' => $this->getCheckedValue(), 'unChecked' => $this->getUncheckedValue());
     return parent::render($view);
 }
 public function isValid($value, $context = null)
 {
     /*        $storeInfo = $this->getStoreInfo();
             if (!empty($storeInfo)) {
                 $this->setRegisterInArrayValidator(false);
             }
     */
     return parent::isValid($value, $context);
 }