Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function getValue()
 {
     if (null === $this->value) {
         $this->value = __('Submit');
     }
     return parent::getValue();
 }
Beispiel #2
0
 /**
  * Retrieve the element value
  *
  * If the value is a DateTime object, and $returnFormattedValue is true
  * (the default), we return the string
  * representation using the currently registered format.
  *
  * If $returnFormattedValue is false, the original value will be
  * returned, regardless of type.
  *
  * @param  bool $returnFormattedValue
  * @return mixed
  */
 public function getValue($returnFormattedValue = true)
 {
     $value = parent::getValue();
     if (!$value instanceof PhpDateTime || !$returnFormattedValue) {
         return $value;
     }
     $format = $this->getFormat();
     return $value->format($format);
 }
Beispiel #3
0
    public function __invoke(Element $element)
    {
        $value = $element->getValue();
        if (!$value) {
            $value = 'default';
        }
        $view = $this->getView();
        $default = $view->escapeHtmlAttr($view->basePath('img/avatars/' . $value . '.png'));
        $id = uniqid('dialog-', false);
        $element->setOption('dialog_id', $id);
        $name = $view->escapeHtmlAttr($element->getName());
        $html = <<<EOT
<div class="zource-avatar-selection zui-file-selection-trigger-container" data-zui-file-selection-trigger="#file-selection-{$id}">
    <input type="hidden" name="{$name}" value="{$value}">

    <p>
        <img src="{$default}" alt="Avatar" tabindex="1" class="zui-file-selection-trigger-thumb">
    </p>
</div>
EOT;
        return $html;
    }
Beispiel #4
0
 /**
  * Get value
  *
  * If element type is one of the button types, returns the label.
  *
  * @param  \Zend\Form\Element $element
  * @return string|null
  */
 public function getValue($element)
 {
     if (!$element instanceof Element) {
         return null;
     }
     foreach ($this->_buttonTypes as $type) {
         if ($element instanceof $type) {
             if (stristr($type, 'button')) {
                 $element->content = $element->getLabel();
                 return null;
             }
             return $element->getLabel();
         }
     }
     return $element->getValue();
 }
Beispiel #5
0
 public function testPassingConfigObjectToConstructorSetsObjectState()
 {
     $config = new Config($this->getOptions());
     $element = new Element($config);
     $this->assertEquals('changed', $element->getName());
     $this->assertEquals('foo', $element->getValue());
     $this->assertEquals('bar', $element->getLabel());
     $this->assertEquals(50, $element->getOrder());
     $this->assertFalse($element->isRequired());
     $this->assertEquals('bar', $element->foo);
     $this->assertEquals('bat', $element->baz);
 }
Beispiel #6
0
 /**
  * @inheritdoc
  */
 public function getValue()
 {
     return $this->element->getValue();
 }
Beispiel #7
0
 /**
  * Gets the user entity or null.
  *
  * @return UserInterface|null
  */
 public function getUser()
 {
     $value = parent::getValue();
     return $value instanceof UserInterface ? $value : null;
 }