Exemplo n.º 1
0
 public function testIntegerCheckedValue()
 {
     $element = new CheckboxElement();
     $element->setCheckedValue(123);
     $this->assertEquals(false, $element->isChecked());
     $element->setAttribute('value', 123);
     $this->assertEquals(true, $element->isChecked());
 }
Exemplo n.º 2
0
 /**
  * License form
  *
  * @return void
  */
 public function license()
 {
     $acceptLicense = new Element\Checkbox('accept-license');
     $acceptLicense->setCheckedValue('1')->setUseHiddenElement(false)->setAttribute('id', 'accept-license')->setAttribute('class', 'input-checkbox');
     $inputFilter = $this->getInputFilter();
     $inputFilter->add(array('name' => 'accept-license', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'greaterthan', 'options' => array('min' => 0)))), 'accept-license');
     $this->add($acceptLicense);
 }
Exemplo n.º 3
0
 public function __construct($name = null)
 {
     parent::__construct('page');
     $id_hidden = new Element\Hidden('id');
     $id_hidden->setName('id');
     $title_text = new Element\Text('title');
     $title_text->setLabel('Title');
     $title_text->setLabelAttributes(array('class' => 'type_text type_text_short'));
     $title_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => 'require'));
     $url_text = new Element\Text('url');
     $url_text->setLabel('Url');
     $url_text->setLabelAttributes(array('class' => 'type_text type_text_short'));
     $url_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => 'require'));
     $text_textarea = new Element\Textarea('text');
     $text_textarea->setLabel('Text');
     $text_textarea->setLabelAttributes(array('class' => 'type_text'));
     $text_textarea->setAttributes(array('placeholder' => 'Type something...'));
     $auto_check = new Element\Checkbox('auto');
     $auto_check->setLabel('Automatically');
     $auto_check->setLabelAttributes(array('class' => 'type_text type_check'));
     $auto_check->setUseHiddenElement(true);
     $auto_check->setCheckedValue("1");
     $auto_check->setUncheckedValue("0");
     $auto_check->setValue('1');
     $meta_text = new Element\Text('meta');
     $meta_text->setLabel('Meta');
     $meta_text->setLabelAttributes(array('class' => 'type_text type_text_mod_darker'));
     $meta_text->setAttributes(array('class' => 'type_text_input'));
     $keywords_text = new Element\Text('keywords');
     $keywords_text->setLabel('Keywords');
     $keywords_text->setLabelAttributes(array('class' => 'type_text type_text_mod_darker'));
     $keywords_text->setAttributes(array('class' => 'type_text_input'));
     $desc_text = new Element\Text('description');
     $desc_text->setLabel('Description');
     $desc_text->setLabelAttributes(array('class' => 'type_text type_text_mod_darker'));
     $desc_text->setAttributes(array('class' => 'type_text_input'));
     $submit_button = new Element\Submit('submit');
     $submit_button->setValue('Submit');
     $submit_button->setAttributes(array('class' => 'btn btn_white'));
     $cancel_button = new Element\Submit('cancel');
     $cancel_button->setValue('Cancel');
     $cancel_button->setAttributes(array('class' => 'btn btn_rozy'));
     $this->add($id_hidden);
     $this->add($title_text);
     $this->add($url_text);
     $this->add($text_textarea);
     $this->add($auto_check);
     $this->add($meta_text);
     $this->add($keywords_text);
     $this->add($desc_text);
     $this->add($submit_button);
     $this->add($cancel_button);
 }
Exemplo n.º 4
0
 public function __construct()
 {
     parent::__construct('loginForm');
     $this->setAttributes(array('id' => 'loginForm', 'role' => 'form', 'method' => 'post'));
     $username = new Element('username');
     $username->setLabel('Nombre de Usuario');
     $username->setAttributes(array('type' => 'text', 'placeholder' => 'Escribe tu Nombre de Usuario', 'id' => 'username', 'class' => 'form-control'));
     $password = new Element\Password('password');
     $password->setLabel('Contraseña');
     $password->setAttributes(array('placeholder' => 'Escribe tu Contraseña', 'id' => 'password', 'class' => 'form-control'));
     $remember = new Element\Checkbox('remember');
     $remember->setLabel('Mantener mi sesión activa');
     $remember->setUseHiddenElement(true);
     $remember->setCheckedValue("1");
     $remember->setUncheckedValue("0");
     $remember->setAttributes(array('id' => 'remember'));
     $loginButton = new Element\Button('loginButton');
     $loginButton->setLabel('Inicia Sesión');
     $loginButton->setAttributes(array('class' => 'btn btn-primary', 'type' => 'submit', 'id' => 'loginButton'));
     $this->add($username);
     $this->add($password);
     $this->add($remember);
     $this->add($loginButton);
 }
Exemplo n.º 5
0
 public function addElements()
 {
     //-- Full name --
     $full_name = new Element\Text('full_name');
     $full_name->setAttribute('placeholder', 'Full Name');
     $full_name->setAttribute('class', 'form-control');
     $full_name->setAttribute('id', 'full-name');
     $full_name->setLabel('Full name');
     $full_name->setLabelAttributes(array('class' => 'control-label', 'for' => 'full-name'));
     //-- Bio --
     $bio = new Element\Textarea('bio');
     $bio->setAttribute('placeholder', 'Bio');
     $bio->setAttribute('class', 'form-control');
     $bio->setAttribute('id', 'bio');
     $bio->setLabel('Bio');
     $bio->setLabelAttributes(array('class' => 'control-label', 'for' => 'bio'));
     //-- Link skype --
     $link_skype = new Element\Text('link_skype');
     $link_skype->setAttribute('placeholder', 'skype_name');
     $link_skype->setAttribute('class', 'form-control');
     $link_skype->setAttribute('id', 'link-skype');
     $link_skype->setLabel('Skype');
     $link_skype->setLabelAttributes(array('class' => 'control-label', 'for' => 'link-skype'));
     //-- Link site --
     $link_site = new Element\Text('link_site');
     $link_site->setAttribute('placeholder', 'http://my-site.com');
     $link_site->setAttribute('class', 'form-control');
     $link_site->setAttribute('id', 'link-site');
     $link_site->setLabel('Link my site');
     $link_site->setLabelAttributes(array('class' => 'control-label', 'for' => 'link-site'));
     //-- Link vkontakte --
     $link_vk = new Element\Text('link_vk');
     $link_vk->setAttribute('placeholder', 'http://vk.com/user_name');
     $link_vk->setAttribute('class', 'form-control');
     $link_vk->setAttribute('id', 'link-vk');
     $link_vk->setLabel('Link VKontakte');
     $link_vk->setLabelAttributes(array('class' => 'control-label', 'for' => 'link-vk'));
     //-- Link facebook --
     $link_fb = new Element\Text('link_fb');
     $link_fb->setAttribute('placeholder', 'https://www.facebook.com/user_name');
     $link_fb->setAttribute('class', 'form-control');
     $link_fb->setAttribute('id', 'link-fb');
     $link_fb->setLabel('Link Facebook');
     $link_fb->setLabelAttributes(array('class' => 'control-label', 'for' => 'link-fb'));
     //-- Link twitter --
     $link_tw = new Element\Text('link_tw');
     $link_tw->setAttribute('placeholder', 'https://twitter.com/user_name');
     $link_tw->setAttribute('class', 'form-control');
     $link_tw->setAttribute('id', 'link-tw');
     $link_tw->setLabel('Link Twitter');
     $link_tw->setLabelAttributes(array('class' => 'control-label', 'for' => 'flink-tw'));
     //-- Password --
     $check = new Element\Checkbox('is_active');
     $check->setAttribute('class', 'form-control');
     $check->setAttribute('id', 'is-active');
     $check->setCheckedValue("1");
     $check->setUncheckedValue("0");
     $check->setLabel('Is active');
     $check->setLabelAttributes(array('class' => 'control-label', 'for' => 'is-active'));
     //-- Submit --
     $submit = new Element\Submit('submit');
     $submit->setAttribute('class', 'btn btn-success');
     $submit->setValue('Send');
     // Binding elements
     $this->add($full_name);
     $this->add($bio);
     $this->add($link_skype);
     $this->add($link_site);
     $this->add($link_vk);
     $this->add($link_fb);
     $this->add($link_tw);
     $this->add($check);
 }
Exemplo n.º 6
0
 /**
  * Add property sub form
  *
  * @param mixed $property \Gc\Property\Model|array
  *
  * @return DocumentType
  */
 public function addProperty($property)
 {
     if (!is_array($property) and !$property instanceof Property\Model) {
         return $this;
     }
     $fieldsets = $this->getProperties();
     $name = new Element\Text('name');
     $identifier = new Element('identifier');
     $tab = new Element\Select('tab');
     $tab->setAttribute('class', 'select-tab')->setValueOptions(array());
     $datatype = new Element\Select('datatype');
     $datatype->setAttribute('class', 'select-datatype')->setValueOptions($this->datatypeCollection->getSelect());
     $description = new Element\Text('description');
     $required = new Element\Checkbox('required');
     $required->setCheckedValue('1')->setAttribute('id', 'required')->setAttribute('class', 'input-checkbox');
     $propertyId = new Element\Hidden('property_id');
     if ($property instanceof Property\Model) {
         $name->setValue($property->getName());
         $identifier->setValue($property->getIdentifier());
         $tab->setValue($property->getTabId());
         $datatype->setValue($property->getDatatypeId());
         $description->setValue($property->getDescription());
         $required->setValue((string) $property->isRequired());
         $propertyId->setValue($property->getId());
         $propertyFieldsetName = $property->getId();
     } else {
         $name->setValue($property['name']);
         $identifier->setValue($property['identifier']);
         $tab->setValue($property['tab']);
         $datatype->setValue($property['datatype']);
         $description->setValue($property['description']);
         $required->setValue((string) (!empty($property['isRequired'])));
         $propertyId->setValue(str_replace('property', '', $property['id']));
         $propertyFieldsetName = $property['id'];
     }
     $propertyForm = new FieldSet($propertyFieldsetName);
     $propertyForm->add($propertyId);
     $propertyForm->add($name);
     $propertyForm->add($identifier);
     $propertyForm->add($tab);
     $propertyForm->add($datatype);
     $propertyForm->add($description);
     $propertyForm->add($required);
     $fieldsets->add($propertyForm);
     $this->getInputFilter()->get('properties')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'tab' => array('name' => 'tab', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'datatype' => array('name' => 'datatype', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'required' => array('name' => 'required', 'required' => false, 'allow_empty' => true)), $propertyFieldsetName);
     return $this;
 }