-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BC: Compatibility with nette/forms 3.1.14
renamed addDate, addDateTime to addBootstrapDate and addBootstrapDateTime. added Date/DateTime/Time/Color inputs which acts as default nette forms
- Loading branch information
Showing
9 changed files
with
201 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<phpunit bootstrap="tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="all"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> | ||
<?xml version="1.0"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="all"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Contributte\FormsBootstrap\Inputs; | ||
|
||
use Contributte\FormsBootstrap\BootstrapUtils; | ||
use Contributte\FormsBootstrap\Traits\StandardValidationTrait; | ||
use Nette\Utils\Html; | ||
|
||
class ColorPicker extends \Nette\Forms\Controls\ColorPicker | ||
{ | ||
|
||
use StandardValidationTrait; | ||
|
||
/** @var string[] */ | ||
public static $additionalHtmlClasses = []; | ||
|
||
/** | ||
* Input accepted format. | ||
* Default is d.m.yyyy | ||
* | ||
* @var string | ||
*/ | ||
private $format; | ||
Check failure on line 23 in src/Inputs/ColorPicker.php GitHub Actions / Static analysis (8.1, ubuntu-latest)
|
||
|
||
/** @var bool */ | ||
private $isValidated = false; | ||
Check failure on line 26 in src/Inputs/ColorPicker.php GitHub Actions / Static analysis (8.1, ubuntu-latest)
|
||
|
||
public function getControl(): Html | ||
{ | ||
$control = parent::getControl(); | ||
BootstrapUtils::standardizeClass($control); | ||
|
||
$control->class[] = 'form-control'; | ||
|
||
return $control; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function validate(): void | ||
{ | ||
parent::validate(); | ||
|
||
$this->isValidated = true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\FormsBootstrap\Inputs; | ||
|
||
use Contributte\FormsBootstrap\BootstrapUtils; | ||
use Contributte\FormsBootstrap\Traits\StandardValidationTrait; | ||
use Nette\Utils\Html; | ||
|
||
class DateTimeControl extends \Nette\Forms\Controls\DateTimeControl | ||
{ | ||
use StandardValidationTrait; | ||
|
||
/** @var string[] */ | ||
public static $additionalHtmlClasses = []; | ||
|
||
/** | ||
* Input accepted format. | ||
* Default is d.m.yyyy | ||
* | ||
* @var string | ||
*/ | ||
private $format; | ||
Check failure on line 22 in src/Inputs/DateTimeControl.php GitHub Actions / Static analysis (8.1, ubuntu-latest)
|
||
|
||
/** @var bool */ | ||
private $isValidated = false; | ||
Check failure on line 25 in src/Inputs/DateTimeControl.php GitHub Actions / Static analysis (8.1, ubuntu-latest)
|
||
|
||
public function getControl(): Html | ||
{ | ||
$control = parent::getControl(); | ||
BootstrapUtils::standardizeClass($control); | ||
|
||
$control->class[] = 'form-control'; | ||
|
||
return $control; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function validate(): void | ||
{ | ||
parent::validate(); | ||
|
||
$this->isValidated = true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Tests\Inputs; | ||
|
||
use Contributte\FormsBootstrap\BootstrapForm; | ||
use Tests\BaseTest; | ||
|
||
class ColorPickerTest extends BaseTest | ||
{ | ||
|
||
public function testDefaultTextInput(): void | ||
{ | ||
$form = new BootstrapForm(); | ||
$input = $form->addColor('color', 'Choose color'); | ||
$this->assertEquals('<input type="color" name="color" id="frm-color" value="#000000" class="form-control">', $input->getControl()->render()); | ||
$this->assertEquals('<label for="frm-color">Choose color</label>', (string) $input->getLabel()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php declare (strict_types = 1); | ||
|
||
namespace Tests\Inputs; | ||
|
||
use Contributte\FormsBootstrap\BootstrapForm; | ||
use Contributte\FormsBootstrap\Enums\DateTimeFormat; | ||
use Contributte\FormsBootstrap\Inputs\DateTimeControl; | ||
use Tests\BaseTest; | ||
|
||
class DateTimeControlTest extends BaseTest | ||
{ | ||
|
||
public function testDefaultDate(): void | ||
{ | ||
$form = new BootstrapForm(); | ||
$dt = $form->addDate('date', 'Date'); | ||
$this->assertEquals('<input type="date" name="date" id="frm-date" class="form-control">', $dt->getControl()->render()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters