public function addElements()
 {
     $id = new Element\Text('id');
     $id->setLabel('ID')->setAttribute('class', 'form-control')->setAttribute('type', 'hidden');
     $this->add($id);
     $name = new Element\Text('name');
     $name->setLabel('catalog name')->setAttribute('class', 'form-control')->setAttribute('required', 'true')->setAttribute('onchange', 'get_alias();')->setAttribute('id', 'name');
     $this->add($name);
     $alias = new Element\Text('alias');
     $alias->setLabel('catalog alias')->setAttribute('required', 'true')->setAttribute('class', 'form-control')->setAttribute('id', 'alias');
     $this->add($alias);
     $description = new Element\Textarea('description');
     $description->setLabel('Description')->setAttribute('class', 'materialize-textarea form-control')->setAttribute('id', 'description');
     $this->add($description);
     $hot = new Element\Radio('hot');
     $hot->setLabel('Choice hot')->setValueOptions(array('0' => 'No Hot', '1' => 'Hot'))->setAttribute('id', 'hot')->setAttribute('class', 'radio_style');
     $this->add($hot);
     $new = new Element\Radio('new');
     $new->setLabel('Choice new')->setValueOptions(array('0' => 'No New', '1' => 'New'))->setAttribute('id', 'new')->setAttribute('class', 'radio_style');
     $this->add($new);
     $status = new Element\Radio('status');
     $status->setLabel('status');
     //->setAttribute('required', 'true')
     $status->setValueOptions(array('0' => 'Pause', '1' => 'Active'))->setAttribute('id', 'status')->setAttribute('class', 'radio_style');
     $this->add($status);
     $show_index = new Element\Radio('show_index');
     $show_index->setLabel('show_index');
     //->setAttribute('required', 'true')
     $show_index->setValueOptions(array('0' => 'No', '1' => 'Yes'))->setAttribute('id', 'show_index')->setAttribute('class', 'radio_style');
     $this->add($show_index);
     $img = new Element\File('img');
     $img->setLabel('file img (* not support .png , .gif)')->setAttribute('class', 'form-control')->setAttribute('type', 'file')->setAttribute('accept', '.jpg, .jpeg, .JPG, .JPEG')->setAttribute('id', 'img');
     $this->add($img);
 }
 public function __construct(EntityManager $entityManager)
 {
     parent::__construct();
     $this->entityManager = $entityManager;
     $this->setAttributes(array("method" => "post", "enctype" => "multipart/form-data", "class" => "form"));
     $this->setInputFilter(new HomeBannersFilters());
     // Campo de titulo
     $titulo = new Text('titulo');
     $titulo->setLabel("* Título")->setAttributes(array("maxLength" => "400", "class" => "form-control", "required" => "required"));
     // Campo tipo de midia
     $tipo = new Radio('tipo_banner');
     $tipo->setLabel('Tipo de mídia');
     $tipo->setValueOptions(array('IMAGEM' => 'Imagem', 'VIDEO' => 'Vídeo'))->setOptions(array('label_attributes' => array('class' => 'radio-inline')))->setAttribute("value", "IMAGEM");
     // Campo de midia
     $file = new File("midia");
     $file->setLabel('*Imagem (Tamanho exato de ' . \Base\Constant\Upload::BANNER_WIDTH . 'x' . \Base\Constant\Upload::BANNER_HEIGTH . ' px | ' . \Base\Constant\Upload::BANNER_MAX_SIZE . ')')->setAttribute('name', 'midia')->setAttribute('id', 'image');
     // Campo de midia2
     $file2 = new File("midia2");
     $file2->setLabel('*Video (' . \Base\Constant\Upload::BANNER_MAX_SIZE . ')')->setAttribute('id', 'video');
     // Botão de Submit
     $botao = new Submit("submit");
     $botao->setAttributes(array("value" => "Salvar"));
     // Adiciona campos
     $this->add($titulo)->add($tipo)->add($file)->add($file2)->add($botao);
 }
Exemple #3
0
 public function testDisableInputSpecification()
 {
     $element = new RadioElement();
     $element->setValueOptions(array('Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3'));
     $element->setDisableInArrayValidator(true);
     $inputSpec = $element->getInputSpecification();
     $this->assertArrayNotHasKey('validators', $inputSpec);
 }
Exemple #4
0
 /**
  * Load radiobuttonlist editor
  *
  * @return Element\Radio
  */
 public function load()
 {
     $parameters = $this->getConfig();
     $element = new Element\Radio($this->getName());
     if (!empty($parameters)) {
         $element->setValueOptions($parameters);
     }
     $element->setLabel($this->getProperty()->getName())->setAttribute('id', $this->getName())->setAttribute('required', $this->getProperty()->isRequired())->setValue($this->getValue());
     return $element;
 }
Exemple #5
0
 public function __construct($name = NULL)
 {
     parent::__construct($name);
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-signin');
     $this->add(array('name' => 'usuario', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'class' => 'search-query')));
     $valor = new Element\Radio('valor');
     $valor->setLabel("Valoración:");
     $valor->setValueOptions(array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10'));
     $this->add($valor);
 }
Exemple #6
0
 protected function addRadio($name, $label, array $data)
 {
     $radio = new Element\Radio($name);
     $radio->setLabel($label);
     $radio->setLabelAttributes(array('class' => "col-sm-{$this->labelWidth}"));
     $radio->setValueOptions($data);
     $radio->setOption('column-size', "sm-{$this->controlWidth}");
     $radio->setOption('inline', true);
     $radio->setOption('disable-twb', true);
     $this->add($radio);
     return $this;
 }
 public function __construct($name = null, $options = null)
 {
     parent::__construct('resposta', $options);
     $this->setInputFilter(new RespostaFilter());
     $this->setAttribute('method', 'Post');
     $id = new Element\Hidden('id');
     $this->add($id);
     $nome = new Element\Text("nome");
     $nome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Entre com a pergunta', 'disabled' => true));
     $this->add($nome);
     $resposta = new Element\Radio('resposta');
     $resposta->setValueOptions(array('1' => 'Sim', '0' => 'Não'));
     $this->add($resposta);
     $this->add(array('name' => 'submit', 'type' => 'Submit', 'attributes' => array('value' => 'Salvar', 'class' => 'btn btn-success col-xs-6 col-md-5 btnSpacer')));
 }
 public function __construct($serviceLocator, $options = null)
 {
     parent::__construct('AccountIndex');
     $this->setServiceLocator($serviceLocator);
     $this->setAttribute('method', 'post');
     $filter = $this->getInputFilter();
     $group = new DisplayGroup('Search');
     $group->setLabel('Tìm kiếm trợ giúp ??');
     $this->add($group);
     // search
     $search = new Text('search');
     $search->setLabel('Tôi cần giúp về: ');
     $search->setAttributes(['maxlength' => 255, 'class' => 'input-title', 'placeholder' => 'e.g. Need help debugging SASS/CSS for frontend in Rails app']);
     $this->add($search);
     $group->addElement($search);
     $filter->add(array('name' => 'search', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
     $searchDetail = new Textarea('searchDetail');
     $searchDetail->setAttributes(['placeholder' => 'Thêm chi tiết giúp bạn nhận hỗ trợ nhanh hơn', 'class' => 'input-description']);
     $this->add($searchDetail);
     $group->addElement($searchDetail);
     $filter->add(array('name' => 'searchDetail', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
     $subject = new Text('subject');
     $subject->setAttributes(['placeholder' => 'Thêm môn học']);
     $this->add($subject);
     $filter->add(array('name' => 'subject', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
     $subjectId = new Hidden('subjectId');
     $this->add($subjectId);
     $filter->add(array('name' => 'subjectId', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn cần điền ít nhất là 1 môn học'))))));
     $budget = new Radio('budget');
     $budget->setValueOptions(['5' => '20', '10' => '40']);
     $this->add($budget);
     $filter->add(array('name' => 'budget', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
     $email = new Text('email');
     $email->setLabel('Email');
     $this->add($email);
     $filter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), array('name' => 'EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Địa chỉ email không hợp lệ'))))));
     $password = new Password('password');
     $password->setAttributes(array('type' => 'password', 'id' => 'password'));
     $password->setLabel('Mật khẩu:');
     $this->add($password);
     //$groupBasic->addElement($password);
     $filter->add(array('name' => 'password', 'required' => false, 'validators' => array(array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập mật khẩu'))))));
     $this->add(array('name' => 'submit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'submit', 'value' => 'Lưu', 'id' => 'btnSave', 'class' => 'btn btn-primary')));
 }
Exemple #9
0
 public function prepare()
 {
     if ($this->isPrepared) {
         return $this;
     }
     $email = new Email('email');
     $email->setLabel('Email');
     $password = new Password('password');
     $password->setLabel('P2assword');
     $member = new Radio('memberOf');
     $member->setValueOptions(array('__model.id__' => '__model.name__'));
     $memberOfTemplate = new TemplateCollection('memberOfTemplate');
     $memberOfTemplate->setTargetElement($member);
     $memberOf = new Fieldset('memberOfGroup');
     $memberOf->setLabel('Member of')->add($memberOfTemplate);
     $submit = new Submit('register');
     $submit->setValue('Register');
     $this->add($memberOf)->add($submit);
     return parent::prepare();
 }
Exemple #10
0
 public function __construct($name = NULL)
 {
     parent::__construct($name);
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'nombre', 'options' => array('label' => 'Empresa'), 'attributes' => array('type' => 'text', 'placeholder' => 'Tu Empresa', 'class' => 'input')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'email', 'options' => array('label' => 'Email'), 'attributes' => array('placeholder' => '*****@*****.**')));
     $this->add(array('type' => 'textarea', 'name' => 'servicios', 'options' => array('label' => 'Servicios'), 'attributes' => array('placeholder' => 'Que ofrece tu empresa', 'rows' => '10')));
     $this->add(array('type' => 'submit', 'name' => 'send', 'attributes' => array('value' => 'Publicar', 'class' => 'btn btn-lg btn-primary btn-block')));
     $this->add(array('type' => 'file', 'name' => 'file', 'attributes' => array('id' => 'file')));
     //* Campo tipo password
     $this->add(array('name' => 'password', 'options' => array('label' => 'Empresa'), 'attributes' => array('type' => 'password', 'placeholder' => 'password', 'class' => 'input')));
     $paquete = new Element\Radio('paquete');
     $paquete->setLabel("Paquete:");
     $paquete->setValueOptions(array('0' => 'Gratuito :: $0.00', '1' => utf8_encode('Básico :: $50.00 Mensual'), '2' => 'Estandard :: $300.00 Mensual', '3' => 'Premium :: $589.00 Mensual'));
     $this->add($paquete);
     $ciudad = new Element\Select('ciudad');
     $ciudad->setLabel("Ciudad:");
     $ciudad->setEmptyOption('Seleccione la ciudad...');
     $ciudad->setValueOptions(array('Xalapa' => 'Xalapa', 'Veracruz' => 'Veracruz', 'Actopan' => 'Actopan', 'Coatzacoalcos' => 'Coatzacoalcos'));
     $this->add($ciudad);
 }
Exemple #11
0
 public function __construct($name = null)
 {
     parent::__construct('terms');
     $id_hidden = new Element\Hidden('id');
     $id_hidden->setName('id');
     $orders_radio = new Element\Radio('custom_orders');
     $orders_radio->setLabel('Custom orders');
     $orders_radio->setValueOptions(array('0' => 'No', '1' => 'Yes'));
     $shipping_select = new Element\Select('shipping');
     $shipping_select->setLabel('Shipping');
     $shipping_select->setLabelAttributes(array('class' => 'select f_3_w50'));
     $shipping_select->setAttributes(array('class' => 'sel_chosen'));
     $shipping_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your shipping'));
     $policies_text = new Element\Textarea('wholesale_policies');
     $policies_text->setLabel('Wholesale policies');
     $policies_text->setLabelAttributes(array('class' => 'type_text'));
     $policies_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...'));
     $this->add($id_hidden);
     $this->add($orders_radio);
     $this->add($shipping_select);
     $this->add($policies_text);
 }
 public function testCanTranslateContent()
 {
     $element = new RadioElement('foo');
     $element->setValueOptions(array(array('label' => 'label1', 'value' => 'value1')));
     $markup = $this->helper->render($element);
     $mockTranslator = $this->getMock('Zend\\I18n\\Translator\\Translator');
     $mockTranslator->expects($this->exactly(1))->method('translate')->will($this->returnValue('translated content'));
     $this->helper->setTranslator($mockTranslator);
     $this->assertTrue($this->helper->hasTranslator());
     $markup = $this->helper->__invoke($element);
     $this->assertContains('>translated content<', $markup);
 }
Exemple #13
0
 /**
  * Builds time fieldset and returns it.
  * 
  * @return Fieldset
  */
 public function getTimeFieldset()
 {
     $timeFieldset = new Fieldset('time');
     // Picker field
     $picker = new Element\Radio('picker');
     $picker->setLabel('Pick Time');
     $picker->setValueOptions($this->_timeOptions);
     $picker->setValue(self::SPECIFIC_TIME);
     $timeFieldset->add($picker);
     // Attach "child" fieldsets
     $timeFieldset->add($this->getSpecificTimeFieldset());
     $timeFieldset->add($this->getEveryHourFieldset());
     $timeFieldset->add($this->getEveryMinuteFieldset());
     return $timeFieldset;
 }
Exemple #14
0
 public function __construct($serviceLocator, $options = null)
 {
     parent::__construct('AccountIndex');
     $this->setServiceLocator($serviceLocator);
     $this->setAttribute('method', 'post');
     $filter = $this->getInputFilter();
     $group = new DisplayGroup('Subject');
     $group->setLabel('Trở thành mentor  ');
     $this->add($group);
     // name
     $fullname = new Text('fullname');
     $fullname->setLabel('Họ và tên:');
     $fullname->setAttributes(['maxlength' => 255, 'placeholder' => 'Tên']);
     $this->add($fullname);
     $group->addElement($fullname);
     $filter->add(array('name' => 'fullname', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập tên'))))));
     $email = new Text('email');
     $email->setLabel('Email của Anh/Chị :');
     $email->setAttributes(['maxlength' => 255, 'placeholder' => 'Email']);
     $this->add($email);
     $group->addElement($email);
     $filter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập email'))), array('name' => 'EmailAddress', 'break_chain_on_failure' => true, 'options' => array('messages' => array('emailAddressInvalidFormat' => 'Địa chỉ email không hợp lệ'))))));
     $skype = new Text('skype');
     $skype->setLabel('Skype:');
     $skype->setAttributes(['maxlength' => 255, 'placeholder' => 'Skype']);
     $this->add($skype);
     $group->addElement($skype);
     $filter->add(array('name' => 'skype', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập skype'))))));
     $mobile = new Text('mobile');
     $mobile->setLabel('Số điện thoại:');
     $mobile->setAttributes(['maxlength' => 12, 'placeholder' => 'Số điện thoại']);
     $this->add($mobile);
     $group->addElement($mobile);
     $filter->add(array('name' => 'mobile', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập số điện thoại'))))));
     $social = new Text('social');
     $social->setLabel('Link tới tài khoản mạng xã hội của bạn:');
     $social->setAttributes(['maxlength' => 255, 'placeholder' => 'Mạng xã hội']);
     $this->add($social);
     $group->addElement($social);
     $filter->add(array('name' => 'social', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập skype'))))));
     $isTeaching = new Radio('isTeaching');
     $isTeaching->setLabel('Bạn đã từng giảng dạy chưa?');
     $isTeaching->setValueOptions(['1' => 'Đã từng', '2' => 'Chưa bao giờ']);
     $this->add($isTeaching);
     $group->addElement($isTeaching);
     $filter->add(array('name' => 'isTeaching', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa chọn'))))));
     $description = new Textarea('description');
     $description->setLabel('Mô tả công việc giảng dạy của bạn:');
     $description->setAttributes(['class' => ' inputBox', 'style' => 'min-height: 300px;', 'placeholder' => 'Mô tả']);
     $this->add($description);
     $group->addElement($description);
     $filter->add(array('name' => 'description', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập mô tả công việc giảng day của bạn'))))));
     $cityId = new Select('cityId');
     $cityId->setLabel('Thành phố:');
     $this->loadCities($cityId);
     $filter->add(array('name' => 'cityId', 'required' => false, 'filters' => array()));
     $this->add($cityId);
     $districtId = new Select('districtId');
     $districtId->setLabel('Quận/huyện: ');
     $this->loadDistricts($districtId, $cityId, $options);
     $this->add($districtId);
     $filter->add(array('name' => 'districtId', 'required' => false, 'filters' => array()));
     $address = new Text('address');
     $address->setLabel('Địa chỉ: ');
     $filter->add(array('name' => 'address', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập địa chỉ của bạn'))))));
     $this->add($address);
     //        $birthday = new Text('birthday');
     //        $birthday->setLabel('Tên danh mục:');
     //        $birthday->setAttributes([
     //            'maxlength' => 255,
     //            'placeholder' => 'Ngày sinh',
     //            'class' =>  'datepicker inputBox'
     //        ]);
     //        $this->add($birthday);
     //        $group->addElement($birthday);
     //        $filter->add(array(
     //            'name' => 'birthday',
     //            'required' => false,
     //            'filters' => array(
     //                array(
     //                    'name' => 'StringTrim'
     //                )
     //            ),
     //            'validators' => array(
     //                array(
     //                    'name' => 'NotEmpty',
     //                    'break_chain_on_failure' => true,
     //                    'options' => array(
     //                        'messages' => array(
     //                            'isEmpty' => 'Bạn chưa nhập ngày sinh'
     //                        )
     //                    )
     //                ),
     //            )
     //        ));
     $this->add(array('name' => 'submit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'submit', 'value' => 'Lưu', 'id' => 'btnSave', 'class' => 'btn btn-primary')));
 }
 public function render($formPV, $id)
 {
     $form = new Form();
     $form->setAttribute('id', $id);
     $inputFilter = new \Zend\InputFilter\InputFilter();
     $factory = new InputFactory();
     foreach ($formPV as $element) {
         if (isset($element->line_text)) {
             $attributes = $element->line_text[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //$required    = ($attributes->data->required == 'true') ? true : false ;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Text($name);
             $element->setName($label);
             $element->setLabel($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
                 $options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax));
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_email)) {
             $attributes = $element->line_email[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //$required    = ($attributes->data->required == 'true') ? true : false ;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Email($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
                 $options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax));
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_checkbox)) {
             $attributes = $element->line_checkbox[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array();
             $element = new Element\MultiCheckbox($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($innerData as $value) {
                 $values[] = $value->label;
             }
             $element->setValueOptions($values);
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required)));
         }
         if (isset($element->line_paragraph)) {
             $attributes = $element->line_paragraph[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             $required = $attributes->data->required == 'true' ? true : false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Textarea($name);
             $element->setName($label);
             $element->setLabel($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_upload)) {
             $attributes = $element->line_upload[0];
             //print_r($attributes);
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             $required = $attributes->data->required == 'true' ? true : false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $filesizeMin = isset($attributes->data->filesize) ? $attributes->data->filesize->min : '';
             $filesizeMax = isset($attributes->data->filesize) ? $attributes->data->filesize->max : '';
             $element = new Element\File($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'validators' => array(array('name' => '\\Zend\\Validator\\File\\Size', 'options' => array('max' => 10 * 1024 * 1024)), array('name' => '\\Zend\\Validator\\File\\Extension', 'options' => array('png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF', 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'Veuillez télécharger une image')))))));
         }
         if (isset($element->line_radio)) {
             $attributes = $element->line_radio[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array();
             $element = new Element\Radio($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($innerData as $value) {
                 $values[] = $value->label;
             }
             $element->setValueOptions($values);
             $form->add($element);
         }
         if (isset($element->line_dropdown)) {
             $attributes = $element->line_dropdown[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $dropdownValues = isset($attributes->data->dropdownValues) ? $attributes->data->dropdownValues : array();
             $element = new Element\Select($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($dropdownValues as $value) {
                 $values[] = $value->dropdown_label;
             }
             $element->setValueOptions($values);
             $form->add($element);
         }
     }
     $form->setInputFilter($inputFilter);
     return $form;
 }
Exemple #16
0
 public function buildForm()
 {
     $this->setAttributes(array('id' => 'post-form', 'method' => 'post'));
     $category = new Element\Select('category');
     $category->setLabel('Categoria');
     $category->setValueOptions(array_combine($this->categories, $this->categories));
     $category->setAttribute('class', 'form-control');
     $title = new Element\Text('title');
     $title->setLabel('Título');
     $title->setAttributes(array('maxlength' => 128, 'class' => 'form-control'));
     $description = new Element\Textarea('description');
     $description->setAttribute('class', 'form-control');
     $description->setLabel('Descrição');
     $photoFilename = new Element\Url('photo_filename');
     $photoFilename->setAttribute('class', 'form-control');
     $photoFilename->setLabel('Foto');
     $contactName = new Element\Text('contact_name');
     $contactName->setAttribute('class', 'form-control');
     $contactName->setLabel('Nome completo');
     $contactEmail = new Element\Email('contact_email');
     $contactEmail->setAttribute('class', 'form-control');
     $contactEmail->setLabel('E-mail');
     $contactPhone = new Element\Text('contact_phone');
     $contactPhone->setAttribute('class', 'form-control');
     $contactPhone->setLabel('Contato');
     $cityCode = new Element\Select('cityCode');
     $cityCode->setAttribute('class', 'form-control');
     $cityCode->setValueOptions($this->cities);
     $cityCode->setLabel('Cidade');
     $deleteCode = new Element\Number('delete_code');
     $deleteCode->setAttribute('class', 'form-control');
     $deleteCode->setLabel('Código de deleção');
     $captcha = new Element\Captcha('captcha');
     $captchaAdapter = new ImageCaptcha(array('font' => './public/fonts/arial.ttf', 'imgDir' => './public/img/captcha', 'imgUrl' => '/img/captcha'));
     $captchaAdapter->setWordlen(4);
     $captcha->setCaptcha($captchaAdapter)->setLabel('Você é um ser humano ou um robô?')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Você é um ser humano ou um robô?');
     /*$captcha = new Element\Captcha('captcha');
             $captcha->setCaptcha(new \Zend\Captcha\Dumb());
             $captcha->setAttribute('class', 'form-control');
             $captcha->setOptions(array('label' => 'Você é um ser humano ou um robô?'));
     */
     $price = new Element\Number('price');
     $price->setAttributes(array('class' => 'form-control', 'maxlength' => 12, 'min' => 0, 'max' => '999999999999'));
     $price->setLabel('Preço');
     $dateExpires = new Element\Radio('date_expires');
     $dateExpires->setLabel('Expira em (dias)');
     $dateExpires->setValueOptions(array_combine($this->dateExpires, $this->dateExpires));
     $csrf = new Element\Csrf('security');
     $submit = new Element\Submit('submit');
     $submit->setAttributes(array('class' => 'btn btn-default', 'value' => 'Enviar formulário'));
     $this->add($category)->add($title)->add($price)->add($dateExpires)->add($description)->add($photoFilename)->add($contactName)->add($contactEmail)->add($contactPhone)->add($cityCode)->add($deleteCode)->add($captcha)->add($csrf)->add($submit);
     /*
             $factory = new \Zend\Form\Factory();
             $factory->createForm(array(
                 'hydrator' => 'Zend\Stdlib\Hydrator\ArraySerializable',
                 'elements' => array(
                     array(
                         'name' => 'category',
                         'type' => 'text',
                         'options' => array(
                             'label' => 'Category'
                         )
                     ),
                     array(
                         'name' => 'title',
                         'type' => 'text',
                         'options' => array(
                             'label' => 'Title'
                         )
                     ),
                 )
             )); */
 }
Exemple #17
0
 /**
  * Add widgets
  *
  * @param string $fieldsetName Fieldset name
  * @param array  $values       Widgets values
  *
  * @return void
  */
 public function addWidget($fieldsetName, $values = array())
 {
     $fieldset = new Fieldset($fieldsetName);
     $this->add($fieldset);
     $name = new Element\Text('name');
     $name->setLabel('Name')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue(isset($values['name']) ? $values['name'] : '');
     $fieldset->add($name);
     $identifier = new Element\Text('identifier');
     $identifier->setLabel('Identifier')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue(isset($values['identifier']) ? $values['identifier'] : '');
     $fieldset->add($identifier);
     $radio = new Element\Radio('settings');
     $radio->setLabel('Sharing Tool')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setValue(isset($values['settings']) ? $values['settings'] : '');
     $radioValues = array();
     foreach ($this->getModel()->getDefaultStyles() as $styleName => $style) {
         $radioValues[$styleName] = array('name' => $style['name'], 'options' => array('img' => isset($style['img']) ? $style['img'] : null));
     }
     $radio->setValueOptions($radioValues);
     $fieldset->add($radio);
     $customString = new Element\Textarea('custom_string');
     $customString->setLabel('Custom string')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue(isset($values['custom_string']) ? $values['custom_string'] : '');
     $fieldset->add($customString);
     $this->add($fieldset);
     $chosenList = new Element\Hidden('chosen_list');
     $chosenList->setValue(isset($values['chosen_list']) ? $values['chosen_list'] : '');
     $fieldset->add($chosenList);
     $this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'settings' => array('name' => 'settings', 'required' => true), 'custom_string' => array('name' => 'custom_string', 'required' => false), 'chosen_list' => array('name' => 'chosen_list', 'required' => false)), $fieldsetName);
 }
 public function testShowErrorInRadio()
 {
     $element = new Element\Radio('direction');
     $element->setLabel("Direction");
     $element->setValueOptions(array('0' => 'programming', '1' => 'design'));
     $element->setMessages(array('Error message'));
     $markup = $this->helper->__invoke($element);
     $this->assertContains('<ul><li>Error message</li></ul>', $markup);
 }
 public function init()
 {
     $paymentType = new Radio('paymentType');
     $paymentType->setAttribute('id', 'paymentType');
     $paymentType->setAttribute('class', 'paymentType');
     $paymentType->setAttribute('title', $this->translator->translate('web.form.document.paymentType.title'));
     $paymentType->setAttribute('required', 'required');
     $paymentType->setLabel($this->translator->translate('web.form.document.paymentType.label'));
     $paymentType->setValueOptions(BankTransaction::$paymentTypes);
     $this->add($paymentType);
     $invoiceText = new Text('invoiceText');
     $invoiceText->setAttribute('id', 'invoiceText');
     $invoiceText->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.invoiceText.placeholder'))->setLabel($this->translator->translate('transaction.form.invoiceText.label'));
     $this->add($invoiceText);
     $invoiceNumber = new Text('invoiceNumber');
     $invoiceNumber->setAttribute('id', 'invoiceNumber');
     $invoiceNumber->setAttribute('class', 'form-control')->setAttribute('readonly', 'readonly')->setAttribute('placeholder', $this->translator->translate('transaction.form.invoiceNumber.placeholder'))->setLabel($this->translator->translate('transaction.form.invoiceNumber.label'));
     $this->add($invoiceNumber);
     $invoiceId = new Text('invoiceId');
     $invoiceId->setAttribute('id', 'invoiceId');
     $this->add($invoiceId);
     $purchInvoiceText = new Text('purchInvoiceText');
     $purchInvoiceText->setAttribute('id', 'purchInvoiceText');
     $purchInvoiceText->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.purchInvoiceText.placeholder'))->setLabel($this->translator->translate('transaction.form.purchInvoiceText.label'));
     $this->add($purchInvoiceText);
     $purchInvoiceNumber = new Text('purchInvoiceNumber');
     $purchInvoiceNumber->setAttribute('id', 'purchInvoiceNumber');
     $purchInvoiceNumber->setAttribute('class', 'form-control')->setAttribute('readonly', 'readonly')->setAttribute('placeholder', $this->translator->translate('transaction.form.purchInvoiceNumber.placeholder'))->setLabel($this->translator->translate('transaction.form.purchInvoiceNumber.label'));
     $this->add($purchInvoiceNumber);
     $purchInvoiceId = new Text('purchInvoiceId');
     $purchInvoiceId->setAttribute('id', 'purchInvoiceId');
     $this->add($purchInvoiceId);
     $paymentDate = new Date('paymentDate');
     $paymentDate->setAttributes(array('id' => 'paymentDate', 'type' => 'text', 'class' => 'input datepicker form-control', 'data-date-weekstart' => 1, 'data-date-format' => 'dd.mm.yyyy'));
     $paymentDate->setAttribute('title', $this->translator->translate('web.form.document.docDate.title'));
     $paymentDate->setAttribute('readonly', 'readonly');
     $paymentDate->setAttribute('placeholder', $this->translator->translate('web.form.document.docDate.placeholder'));
     $paymentDate->setLabel($this->translator->translate('web.form.document.docDate.label'));
     $this->add($paymentDate);
     $type = new Text('type');
     $type->setAttribute('id', 'type');
     $this->add($type);
     $name = new Text('name');
     $name->setAttribute('id', 'name');
     $name->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.name.placeholder'))->setLabel($this->translator->translate('transaction.form.name.label'));
     $this->add($name);
     $referenceNumber = new Text('referenceNumber');
     $referenceNumber->setAttribute('id', 'referenceNumber');
     $referenceNumber->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.referenceNumber.placeholder'))->setLabel($this->translator->translate('transaction.form.referenceNumber.label'));
     $this->add($referenceNumber);
     $sum = new Text('sum');
     $sum->setAttribute('id', 'sum');
     $sum->setAttribute('title', $this->translator->translate('transaction.form.amount.label'));
     $sum->setAttribute('class', 'form-control');
     $sum->setAttribute('required', 'required');
     $sum->setAttribute('placeholder', $this->translator->translate('transaction.form.amount.label'));
     $sum->setLabel($this->translator->translate('transaction.form.amount.label'));
     $this->add($sum);
     $description = new Text('description');
     $description->setAttribute('id', 'description');
     $description->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.description.placeholder'))->setLabel($this->translator->translate('transaction.form.description.label'));
     $this->add($description);
     $payerIban = new Text('payerIban');
     $payerIban->setAttribute('id', 'payerIban');
     $payerIban->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.payerIban.placeholder'))->setLabel($this->translator->translate('transaction.form.payerIban.label'));
     $this->add($payerIban);
     $archiveSign = new Text('archiveSign');
     $archiveSign->setAttribute('id', 'archiveSign');
     $archiveSign->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.archiveSign.placeholder'))->setLabel($this->translator->translate('transaction.form.archiveSign.label'));
     $this->add($archiveSign);
     return $this;
 }