/**
  * @param Element $element
  */
 public function addElement($element)
 {
     $options = $element->getOptions();
     $options['displayGroup'] = $this->getName();
     $element->setOptions($options);
     $this->elements[$element->getName()] = $element;
     return $this;
 }
Example #2
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;
    }
Example #3
0
 /**
  * Add element to stack
  *
  * @param  Element $element
  * @return DisplayGroup
  */
 public function addElement(Element $element)
 {
     $this->_elements[$element->getName()] = $element;
     $this->_groupUpdated = true;
     return $this;
 }
Example #4
0
 public function testSetOptionsIsTraversable()
 {
     $element = new Element('foo');
     $element->setOptions(new \ArrayObject(array('foo' => 'bar')));
     $this->assertEquals('foo', $element->getName());
     $this->assertEquals(array('foo' => 'bar'), $element->getOptions());
 }
Example #5
0
 /**
  * Render element label
  *
  * @param  \Zend\Form\Element $element
  * @param  \Zend\View\Renderer $view
  * @return string
  */
 public function renderLabel(Form\Element $element, View $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
     }
     return $this->getMarkupElementLabelStart() . $view->vars()->escape($label) . $this->getMarkupElementLabelEnd();
 }
Example #6
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);
 }
Example #7
0
 public function testCanPassNameToConstructor()
 {
     $element = new Element('foo');
     $this->assertEquals('foo', $element->getName());
 }
Example #8
0
 /**
  * @inheritdoc
  */
 public function getName()
 {
     return $this->element->getName();
 }