Skip to content

Commit

Permalink
Fixed defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Robert committed Jul 11, 2022
1 parent 00fdca4 commit 89f8837
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions Chase/Safari/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function stringify(): string

public function html()
{
$this->decideValue();
if (!$this->__html__) {
return "<{$this->__name__} " . $this->stringify() . "/>";
} else {
Expand Down
17 changes: 10 additions & 7 deletions Chase/Safari/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ public function input(callable $mutator): Field
*/
public function textarea(callable $mutator): Field
{
$element = new Element('input', static::$request);
$element = new Element('textarea', static::$request);
$mutator($element);
$element->setHtml(function () use ($element) {
return "<textarea " . $element->stringify() . "/></textarea>";

$valueInRequest = static::$request[$element->name ?? ''] ?? null;

$element->setHtml(function () use ($element, $valueInRequest) {
return "<textarea " . $element->stringify() . "/>$valueInRequest</textarea>";
});
$this->elements[] = $element;
return $this;
Expand Down Expand Up @@ -158,10 +161,10 @@ public function radio(callable $mutator): Field
$name = $element->name;

if (!empty(static::$request) && $name) {
$valueInRequest = static::$request[$name];
$valueInRequest = static::$request[$name] ?? null;
if (is_array($valueInRequest) && in_array($element->value, $valueInRequest)) {
$element->checked = 'checked';
} else if (in_array($element->value, $valueInRequest)) {
} else if (in_array($element->value, static::$request)) {
$element->checked = 'checked';
}
}
Expand All @@ -187,10 +190,10 @@ public function checkbox(callable $mutator): Field
$name = $element->name;

if (!empty(static::$request) && $name) {
$valueInRequest = static::$request[$name];
$valueInRequest = static::$request[$name] ?? null;
if (is_array($valueInRequest) && in_array($element->value, $valueInRequest)) {
$element->checked = 'checked';
} else if (in_array($element->value, $valueInRequest)) {
} else if (in_array($element->value, static::$request)) {
$element->checked = 'checked';
}
}
Expand Down

0 comments on commit 89f8837

Please sign in to comment.