Skip to content

Commit

Permalink
support for nette/forms 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dakorpar committed Mar 17, 2024
1 parent 290ad32 commit c0405ce
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 36 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": ">=8.1",
"nette/forms": "3.1.15",
"nette/forms": "3.2.0",
"nette/application": "^3.0"
},
"require-dev": {
Expand Down
7 changes: 2 additions & 5 deletions src/BootstrapForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct($container = null)

$prototype = Html::el('form', [
'action' => '',
'method' => self::POST,
'method' => self::Post,
'class' => [],
]);
$this->elementPrototype = $prototype;
Expand Down Expand Up @@ -98,10 +98,7 @@ public function getRenderer(): FormRenderer
return $renderer;
}

/**
* @return static
*/
public function setRenderer(?FormRenderer $renderer = null)
public function setRenderer(?FormRenderer $renderer = null): static
{
if (!$renderer instanceof BootstrapRenderer) {
throw new InvalidArgumentException('Renderer must be a BootstrapRenderer class');
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public function renderControls($parent): string

// note that these are NOT form groups, these are groups specified to group
foreach ($parent->getControls() as $control) {
if ($control->getOption(RendererOptions::_RENDERED, false)) {
if ($control->getOption(RendererOptions::_RENDERED)) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Grid/BootstrapRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ public function setParent(?IContainer $parent = null, ?string $name = null): sta
* @param mixed|null $default
* @return mixed|null
*/
public function getOption(string $option, $default = null)
public function getOption(string $option)

Check failure on line 203 in src/Grid/BootstrapRow.php

View workflow job for this annotation

GitHub Actions / Static analysis (8.1, ubuntu-latest)

PHPDoc tag @param references unknown parameter: $default

Check failure on line 203 in src/Grid/BootstrapRow.php

View workflow job for this annotation

GitHub Actions / Static analysis (8.1, ubuntu-latest)

PHPDoc tag @param references unknown parameter: $default
{
return $this->options[$option] ?? $default;
return $this->options[$option];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Inputs/ButtonInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getControl($content = null): Html
$btn = parent::getControl($content);
$btn->setName('button');
$this->addBtnClass($btn);
$btn->setHtml($content ?? (string) $this->caption); //@phpstan-ignore-line
$btn->setHtml($content ?? (string) $this->caption);
$btn->removeAttribute('value');

return $btn;
Expand Down
15 changes: 4 additions & 11 deletions src/Inputs/CheckboxInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,15 @@ class CheckboxInput extends Checkbox implements IValidationInput

/**
* set to true so that checkboxes by defaults are alligned on right with input fields, you can also set
*
* @var bool
*/
public static $defaultAllignWithInputControls = false;
public static bool $defaultAllignWithInputControls = false;

/**
* set to true to allign checkbox to right with all other input controls
*
* @var bool
*/
public $allignWithInputControls;
public bool $allignWithInputControls;

/**
* @param string|object $label
*/
public function __construct($label = null)
public function __construct(string|\Stringable|null $label = null)
{
$this->allignWithInputControls = static::$defaultAllignWithInputControls;

Expand All @@ -54,7 +47,7 @@ public function __construct($label = null)
*/
public static function makeCheckbox(
string $name,
string $htmlId,
bool|null|string $htmlId,
$caption = null,
bool $checked = false,
$value = false,
Expand Down
2 changes: 1 addition & 1 deletion src/Inputs/DateInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function cleanErrors(): void
/**
* @inheritdoc
*/
public function getValue()
public function getValue(): mixed
{
$val = parent::getValue();

Expand Down
4 changes: 0 additions & 4 deletions src/Inputs/SelectInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
use Nette\Forms\Controls\SelectBox;
use Nette\Utils\Html;

/**
* Class SelectInput.
* Single select.
*/
class SelectInput extends SelectBox implements IValidationInput
{

Expand Down
5 changes: 1 addition & 4 deletions src/Inputs/TextInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ public function setPlaceholder(string $placeholder)
return $this;
}

/**
* @param object|string $caption
*/
public function getLabel($caption = null): Html
public function getLabel(string|\Stringable|null $caption = null): Html
{
/** @var Html $label */
$label = parent::getLabel($caption);
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/BootstrapContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function addEmail(string $name, $label = null): NetteTextInput
{
return $this->addText($name, $label)
->setNullable(BootstrapForm::$allwaysUseNullable)
->addRule(Form::EMAIL);
->addRule(Form::Email);
}

/**
Expand All @@ -207,7 +207,7 @@ public function addInteger(string $name, $label = null): NetteTextInput
{
return $this->addText($name, $label)
->setNullable(BootstrapForm::$allwaysUseNullable)
->addRule(Form::INTEGER);
->addRule(Form::Integer);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Traits/InputPromptTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ trait InputPromptTrait

/**
* Sets the first unselectable item on list. Its value is null.
*
* @param string|null $prompt
* @return static
*/
public function setPrompt($prompt)
public function setPrompt(string|\Stringable|false $prompt): static
{
if (empty($prompt)) {
return $this;
Expand Down

0 comments on commit c0405ce

Please sign in to comment.