예제 #1
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;
    }
예제 #2
0
 public function testCanSetSingleOptionForLabel()
 {
     $element = new Element('foo');
     $element->setOption('label', 'foo');
     $option = $element->getOption('label');
     $this->assertEquals('foo', $option);
 }
예제 #3
0
 protected function generateFormElementByType($name, $type, $values = array(), $priority)
 {
     switch ($type) {
         case 'FILE':
             $elm = new Element\File();
             $elm->setLabel(strtoupper($name));
             break;
         case 'SELECT':
             $elm = new Element\Select($name);
             $elm->setLabel(strtoupper($name));
             $elm->setAttribute('id', $name . '_ID');
             if ($values instanceof \Traversable || is_array($values)) {
                 $elm->setValueOptions($values);
             }
             break;
         case 'DATE':
             if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
                 $elm = new \Zf2datatable\Form\Element\DateCalendar($name);
                 $elm->setAttribute('id', $name . '_ID');
                 $elm->setAttribute('class', 'form-control');
                 $elm->setLabel($name);
                 $elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['date_js_properties']);
                 \Zf2datatable\Form\Element\DateCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['date_format_in']);
                 \Zf2datatable\Form\Element\DateCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['date_format_out']);
             } else {
                 $elm = new Element\Date($name);
                 $elm->setLabel(strtoupper($name));
                 $elm->setAttributes(array('type' => 'date'));
                 $elm->setFormat('Y-m-d');
             }
             break;
         case 'DATETIME':
             if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
                 $elm = new \Zf2datatable\Form\Element\DateTimeCalendar($name);
                 $elm->setAttribute('id', $name . '_ID');
                 $elm->setAttribute('class', 'form-control');
                 $elm->setLabel($name);
                 $elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['datetime_js_properties']);
                 \Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['datetime_format_in']);
                 \Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['datetime_format_out']);
             } else {
                 $elm = new Element\DateTimeSelect($name);
                 $elm->setLabel(strtoupper($name));
             }
             break;
         default:
             $elm = new Element($name);
             $elm->setLabel(strtoupper($name));
             $elm->setAttributes(array('type' => 'text'));
             break;
     }
     $elm->setOption('priority', $priority);
     return $elm;
 }