Example #1
0
    public function testRender()
    {
        $options = array('test1' => 'foo', 'test2' => 'bar');
        $testElement = new Select('select', $options, ['name' => 'select[]']);
        $this->form->get('select')->addOptions($options);
        $this->assertEquals($testElement->render(), $this->form->get('select')->render());
        $htmlDecorated = <<<RENDER
<input type="hidden" name="select[]" />
<select id="select" name="select[]" multiple="multiple" data-vegas-multiselect>
    <option value="test1">foo</option>
    <option value="test2">bar</option>
</select>
RENDER;
        $this->assertEquals($testElement->render(['value' => 'test1']), $this->form->get('select')->render(['value' => 'test1']));
        $this->assertEquals($htmlDecorated, $this->form->get('select')->renderDecorated());
    }
Example #2
0
 /**
  * Initializes backend form of pages
  */
 public function initialize()
 {
     $lang = new Select('lang', $this->di->get('config')->application->langs->toArray());
     $lang->setLabel('Language');
     $this->add($lang);
     $title = new Text('title');
     $title->setLabel('Title');
     $title->addValidator(new PresenceOf());
     $title->setAttribute('placeholder', 'Title');
     $this->add($title);
     $content = new Textarea('content');
     $content->setLabel('Content');
     $content->addValidator(new PresenceOf());
     $content->setAttribute('placeholder', 'content');
     $this->add($content);
 }
Example #3
0
 public function __construct($name, $options = null, $attributes = null)
 {
     $templatePath = implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'MultiSelect', 'views', '']);
     $this->setDecorator(new Decorator($templatePath));
     $this->getDecorator()->setTemplateName('jquery');
     $this->setAttribute('name', $name . '[]');
     parent::__construct($name, $options, $attributes);
 }