generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor choice list widgets and add immutability tests. (#215)
- Loading branch information
1 parent
bf84d2a
commit 0176c7e
Showing
27 changed files
with
1,044 additions
and
702 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
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
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
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Input; | ||
|
||
/* | ||
* Generates a list of checkboxes buttons. | ||
* | ||
* A checkbox is a graphical control element that allows the user to choose one or more options from a predefined set of | ||
* mutually exclusive options. | ||
*/ | ||
final class CheckboxList extends Base\AbstractChoiceList | ||
{ | ||
public function items(Checkbox ...$items): static | ||
{ | ||
$new = clone $this; | ||
$new->items = $items; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* This method is used to configure the widget with the provided default definitions. | ||
*/ | ||
public function loadDefaultDefinitions(): array | ||
{ | ||
return [ | ||
'container()' => [true], | ||
'id()' => [$this->generateId('checkboxlist-')], | ||
'template()' => ['{label}\n{tag}'], | ||
]; | ||
} | ||
|
||
protected function run(): string | ||
{ | ||
$this->validateIterable($this->checkedValue); | ||
|
||
return $this->buildChoiceListTag('checkbox'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Input; | ||
|
||
/* | ||
* Generates a list of radio buttons. | ||
* | ||
* A radio button is a graphical control element that allows the user to choose only one of a predefined set of mutually | ||
* exclusive options. | ||
*/ | ||
final class RadioList extends Base\AbstractChoiceList | ||
{ | ||
public function items(Radio ...$items): static | ||
{ | ||
$new = clone $this; | ||
$new->items = $items; | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* This method is used to configure the widget with the provided default definitions. | ||
*/ | ||
public function loadDefaultDefinitions(): array | ||
{ | ||
return [ | ||
'container()' => [true], | ||
'id()' => [$this->generateId('radiolist-')], | ||
'template()' => ['{label}\n{tag}'], | ||
]; | ||
} | ||
|
||
protected function run(): string | ||
{ | ||
$this->validateScalar($this->checkedValue); | ||
|
||
return $this->buildChoiceListTag('radio'); | ||
} | ||
} |
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
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
Oops, something went wrong.