Esempio n. 1
0
 public function __construct()
 {
     $this->labelPosition = static::LABEL_NONE;
     $this->datalistAllowed = false;
     $this->input = (new Elements\Button())->attr('type', 'submit');
     parent::__construct();
 }
Esempio n. 2
0
 public function __construct()
 {
     $this->labelPosition = static::LABEL_AFTER;
     $this->datalistAllowed = false;
     $this->input = new Elements\InputRadio();
     parent::__construct();
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function toHtml()
 {
     if ($this->render) {
         return parent::toHtml();
     }
     $label = isset($this->label) ? (string) $this->label : '';
     return "{$this->input} {$label} {$this->errorLabel}";
 }
Esempio n. 4
0
 public function testField()
 {
     $field = Field::text();
     $this->assertEquals('text', $field->attr('type'));
     $this->assertEquals('text', $field->input->attr('type'));
     $field->label('Label');
     $this->assertEquals('Label', $field->label->html());
     $field->id('my-id');
     $html = '<label for="my-id">Label</label> <input type="text" id="my-id"> ';
     $this->assertEquals($html, $field->toHtml());
     $field->error('Error!!');
     $html .= '<label class="error" for="my-id">Error!!</label>';
     $this->assertEquals($html, $field->toHtml());
 }
Esempio n. 5
0
 public function testForm()
 {
     $form = new Form();
     $form->action('index.php')->method('post');
     $form->add(['name' => Field::text()->maxlength(50)->required()->label('Your name'), 'email' => Field::email()->label('Your email'), 'telephone' => Field::tel()->label('Telephone number'), 'gender' => Field::choose(['m' => Field::radio()->label('Male'), 'f' => Field::radio()->label('Female')]), 'born' => Field::collection(['day' => Field::number()->min(1)->max(31)->label('Day'), 'month' => Field::number()->min(1)->max(12)->label('Month'), 'year' => Field::number()->min(1900)->max(2013)->label('Year')]), 'language' => Field::select()->options(array('gl' => 'Galician', 'es' => 'Spanish', 'en' => 'English'))->label('Language'), 'friends' => Field::duplicable(['name' => Field::text()->label('Name'), 'email' => Field::email()->label('email'), 'age' => Field::number()->label('Age')]), 'action' => Field::choose(['save' => Field::submit()->html('Save changes'), 'duplicate' => Field::submit()->html('Save as new value')])]);
     $data = array('name' => 'Manuel', 'email' => null, 'telephone' => null, 'gender' => 'm', 'born' => array('day' => 23, 'month' => 12, 'year' => 2013), 'language' => 'gl', 'friends' => array(array('name' => 'Luis', 'email' => '*****@*****.**', 'age' => 30)), 'action' => 'save');
     $form->val($data);
     $this->assertTrue($form->isValid());
     $form->addValidator('myValidator', function ($form) {
         $val = $form['name']->val();
         return empty($val) ? true : 'The name value must be empty';
     });
     $this->assertFalse($form->isValid());
     $this->assertEquals('The name value must be empty', $form->error());
 }
Esempio n. 6
0
 public function testRender()
 {
     $input = Field::text()->name('name')->attr('id', 'field-name')->label('Your name');
     $html = '<label for="field-name">Your name</label> <input type="text" name="name" id="field-name"> ';
     $this->assertEquals($html, (string) $input);
     $input->render(function ($input) {
         return $input->label . '<br>' . $input->input;
     });
     $html = '<label for="field-name">Your name</label><br><input type="text" name="name" id="field-name">';
     $this->assertEquals($html, (string) $input);
     $input->render(function ($input) {
         return '<div>' . $input . '</div>';
     });
     $html = '<div><label for="field-name">Your name</label> <input type="text" name="name" id="field-name"> </div>';
     $this->assertEquals($html, (string) $input);
 }
Esempio n. 7
0
 public function __construct()
 {
     $this->input = new Elements\InputEmail();
     parent::__construct();
 }
Esempio n. 8
0
 public function __construct()
 {
     $this->datalistAllowed = false;
     $this->input = (new Elements\Input())->attr('type', 'password');
     parent::__construct();
 }
Esempio n. 9
0
 /**
  * @param array $attributes
  * @return void
  */
 public function setFormElementAttributes(array $attributes)
 {
     $this->formField->attr($attributes);
 }
Esempio n. 10
0
 public function __construct()
 {
     $this->labelPosition = static::LABEL_AFTER;
     $this->input = new Elements\InputCheckbox();
     parent::__construct();
 }
Esempio n. 11
0
 public function __construct()
 {
     parent::__construct((new Elements\Input())->type('hidden'));
     $this->set('list', true);
     $this->wrapper->class('format is-responsive');
 }
Esempio n. 12
0
 public function __construct()
 {
     $this->input = (new Elements\Input())->attr('type', 'text');
     parent::__construct();
 }
Esempio n. 13
0
 private function createShippingAddress($countries, $i18n)
 {
     return Field::group(['use_shipping_address' => Field::checkbox()->label($i18n->translate('checkoutForm.adr.customShippingAdr'))->render(function ($field) {
         return "<h3><label class='checkbox'>{$field->input} " . $field->label() . '</label></h3>';
     }), 'name' => Field::text()->label($i18n->translate('checkoutForm.adr.name')), 'company' => Field::text()->label($i18n->translate('checkoutForm.adr.company')), 'street' => Field::text()->label($i18n->translate('checkoutForm.adr.street')), 'zip' => Field::text()->label($i18n->translate('checkoutForm.adr.zip')), 'city' => Field::text()->label($i18n->translate('checkoutForm.adr.city')), 'country' => Field::select()->options($countries)->label($i18n->translate('checkoutForm.adr.country'))])->render(function ($group) {
         return '<div class="adrGroup">' . $group->childrenToHtml() . '</div>';
     });
 }
Esempio n. 14
0
 public function __construct()
 {
     $this->datalistAllowed = false;
     $this->input = new Elements\Textarea();
     parent::__construct();
 }
Esempio n. 15
0
 public function __construct()
 {
     $this->input = new Elements\InputDatetime();
     parent::__construct();
 }
Esempio n. 16
0
 public function __construct()
 {
     $this->input = (new Elements\InputNumber())->attr('type', 'range');
     parent::__construct();
 }