Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Fixed compatibility with Nette 2.4.0 again
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Jul 15, 2016
1 parent d3890aa commit d0b421f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions src/Nella/Forms/DateTime/DateInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,18 @@ private function normalizeFormat($input)
*/
public function setRequired($message = TRUE)
{
if (!is_bool($message) && !is_string($message)) {
if ($message !== FALSE && !is_string($message)) {
throw new \Nette\InvalidArgumentException('Message must be string');
}

parent::setRequired($message);

$this->addCondition(Form::FILLED)
->addRule(function (DateInput $control) {
return $this->validateDate($control);
}, $message);
if ($message !== FALSE) {
$this->addCondition(Form::FILLED)
->addRule(function (DateInput $control) {
return $this->validateDate($control);
}, $message);
}

return $this;
}
Expand Down
12 changes: 7 additions & 5 deletions src/Nella/Forms/DateTime/DateTimeInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,18 @@ private function normalizeFormat($input)
*/
public function setRequired($message = TRUE)
{
if (!is_bool($message) && !is_string($message)) {
if ($message !== FALSE && !is_string($message)) {
throw new \Nette\InvalidArgumentException('Message must be string');
}

parent::setRequired($message);

$this->addCondition(Form::FILLED)
->addRule(function (DateTimeInput $control) {
return $this->validateDateTime($control);
}, $message);
if ($message !== FALSE) {
$this->addCondition(Form::FILLED)
->addRule(function (DateTimeInput $control) {
return $this->validateDateTime($control);
}, $message);
}

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Nella/Forms/DateTime/DateInputTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class DateInputTest extends \Tester\TestCase
{
$control = $this->createControl();

$control->setRequired(TRUE);
$control->setRequired('Required');
Assert::true($control->isRequired());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Nella/Forms/DateTime/DateTimeInputTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class DateTimeInputTest extends \Tester\TestCase
{
$control = $this->createControl();

$control->setRequired(TRUE);
$control->setRequired('Required');
Assert::true($control->isRequired());
}

Expand Down

0 comments on commit d0b421f

Please sign in to comment.