Skip to content

Commit

Permalink
examples: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 30, 2016
1 parent 296b8c8 commit 2b44619
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions examples/basic-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@
'b' => 'blue',
]);

$form->addText('email', 'Email:')
->setEmptyValue('@')
->addCondition($form::FILLED) // conditional rule: if is email filled, ...
->addRule($form::EMAIL, 'Incorrect email address'); // ... then check email
$form->addEmail('email', 'Email:')
->setEmptyValue('@');


// group Shipping address
Expand Down Expand Up @@ -93,8 +91,8 @@
->addRule($form::EQUAL, 'Passwords do not match', $form['password']);

$form->addUpload('avatar', 'Picture:')
->addCondition($form::FILLED)
->addRule($form::IMAGE, 'Uploaded file is not image');
->setRequired(FALSE)
->addRule($form::IMAGE, 'Uploaded file is not image');

$form->addHidden('userid');

Expand Down
4 changes: 2 additions & 2 deletions examples/custom-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public function setValue($value)


/**
* @return DateTime|NULL
* @return DateTimeImmutable|NULL
*/
public function getValue()
{
return self::validateDate($this)
? (new DateTime)->setDate($this->year, $this->month, $this->day)->setTime(0, 0)
? (new DateTimeImmutable)->setDate($this->year, $this->month, $this->day)->setTime(0, 0)
: NULL;
}

Expand Down
7 changes: 2 additions & 5 deletions examples/html5.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@
->addRule($form::INTEGER, 'Precision must be numeric value')
->addRule($form::RANGE, 'Precision must be in range from %d to %d', [0, 100]);

$form->addText('email', 'Send to email:')
->setType('email')
$form->addEmail('email', 'Send to email:')
->setAttribute('autocomplete', 'off')
->setAttribute('placeholder', 'Optional, but Recommended')
->addCondition($form::FILLED) // conditional rule: if is email filled, ...
->addRule($form::EMAIL, 'Incorrect email address'); // ... then check email
->setAttribute('placeholder', 'Optional, but Recommended');

$form->addSubmit('submit', 'Send');

Expand Down
4 changes: 2 additions & 2 deletions examples/manual-rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
]);

$form->addText('email')
->addCondition($form::FILLED)
->addRule($form::EMAIL, 'Incorrect email address');
->setRequired(FALSE)
->addRule($form::EMAIL, 'Incorrect email address');

$form->addSubmit('submit');

Expand Down

0 comments on commit 2b44619

Please sign in to comment.