Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RadioList.php #83

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 174 additions & 162 deletions composer.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ public function addDateTime(string $name, $label = null, bool $withSeconds = fal
}


public function addDateWeek(string $name, $label = null): Control\TextInput
{
return $this[$name] = (new Control\TextInput($label))
->setHtmlAttribute('type', 'week');
}


public function addTime(string $name, $label = null, bool $withSeconds = false): Control\DateTimeInput
{
return $this[$name] = (new Control\DateTimeInput($label, DateTimeControl::TypeTime, $withSeconds))
Expand Down
5 changes: 2 additions & 3 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,13 @@ public function addDate(string $name, $label = null): Control\DateTimeInput
}


public function addDateWeek(string $name, $label = null): Control\DateTimeInput
public function addDateWeek(string $name, $label = null): Control\TextInput
{
return $this[$name] = (new Control\TextInput($label))
->setHtmlAttribute('type', week);
->setHtmlAttribute('type', 'week');
}



public function addDateTime(string $name, $label = null, bool $withSeconds = false): Control\DateTimeInput
{
$dateInput = new Control\DateTimeInput($label, DateTimeControl::TypeDateTime, $withSeconds);
Expand Down
25 changes: 24 additions & 1 deletion src/control/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class Checkbox extends \Nette\Forms\Controls\Checkbox implements Renderable, Sig

private ?string $inputClass = null;

private ?string $labelClass = null;

private ?string $checkboxClass = null;

private ?string $wrapClass = null;


Expand All @@ -49,6 +53,22 @@ public function setInputWrapClass(string $class): self
}


public function setLabelWrapClass(string $class): self
{
$this->labelClass = $class;

return $this;
}


public function setCheckboxWrapClass(string $class): self
{
$this->checkboxClass = $class;

return $this;
}


public function setWrapClass(string $class): self
{
$this->wrapClass = $class;
Expand Down Expand Up @@ -77,6 +97,8 @@ public function getCoreControl(): string|Html
$labelAttribute = 'width: auto';
}

$labelClass = $this->labelClass ? $labelClass . ' ' . $this->labelClass : $labelClass;

$input->class($inputClass . ' ' . $input->getAttribute('class') . ($validationClass ? ' ' . $validationClass : null));

if($this instanceof \ModulIS\Form\Control\Signalable && $this->hasSignal())
Expand All @@ -91,9 +113,10 @@ public function getCoreControl(): string|Html
->addHtml($this->caption);

$switchClass = $this->switch ? ' form-switch' : null;
$checkboxClass = $this->checkboxClass ? ' ' . $this->checkboxClass : null;

$wrapDiv = Html::el('div')
->class('form-check' . $switchClass)
->class('form-check' . $switchClass . $checkboxClass)
->addHtml($input . $label);

if($this->tooltip)
Expand Down
10 changes: 9 additions & 1 deletion src/control/RadioList.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ public function setBig(bool $big = true): self
}


public function setItemsColor(string $color): self
{
$this->color = $color;

return $this;
}


/**
* @param class-string<BackedEnum&\ModulIS\Form\Enum\RadioEnum> $enumClass
* @param class-string<\BackedEnum&\ModulIS\Form\Enum\RadioEnum> $enumClass
*/
public function setValuesFromEnum(string $enumClass): self
{
Expand Down
2 changes: 2 additions & 0 deletions src/enum/RadioEnum.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ModulIS\Form\Enum;

interface RadioEnum
Expand Down
2 changes: 1 addition & 1 deletion tests/InputTest/ContainerTest/basic.latte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</div>
</div>
</div>
<button name="save" class="btn btn-gray" type="submit" formnovalidate value="Uložit">Uložit</button>
<button name="save" class="btn rounded-pill px-4 btn-gray" type="submit" formnovalidate value="Uložit">Uložit</button>
</div>
</div>
2 changes: 1 addition & 1 deletion tests/InputTest/ContainerTest/card.latte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<div class="card-footer">
<div class="row">
<button name="save" class="btn btn-gray" type="submit" formnovalidate value="Uložit">Uložit</button>
<button name="save" class="btn rounded-pill px-4 btn-gray" type="submit" formnovalidate value="Uložit">Uložit</button>
</div>
</div>
</div>
Expand Down
Loading