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

Add HasColumns trait for checkboxes and radios #2232

Merged
merged 1 commit into from
May 15, 2023
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
2 changes: 2 additions & 0 deletions src/Services/Forms/Fields/Checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace A17\Twill\Services\Forms\Fields;

use A17\Twill\Services\Forms\Fields\Traits\HasBorder;
use A17\Twill\Services\Forms\Fields\Traits\HasColumns;
use A17\Twill\Services\Forms\Fields\Traits\HasMax;
use A17\Twill\Services\Forms\Fields\Traits\HasMin;
use A17\Twill\Services\Forms\Fields\Traits\HasOptions;
Expand All @@ -17,6 +18,7 @@ class Checkboxes extends BaseFormField
use HasMin;
use Inlineable;
use HasBorder;
use HasColumns;

public static function make(): static
{
Expand Down
2 changes: 2 additions & 0 deletions src/Services/Forms/Fields/Radios.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace A17\Twill\Services\Forms\Fields;

use A17\Twill\Services\Forms\Fields\Traits\HasBorder;
use A17\Twill\Services\Forms\Fields\Traits\HasColumns;
use A17\Twill\Services\Forms\Fields\Traits\HasOptions;
use A17\Twill\Services\Forms\Fields\Traits\Inlineable;
use A17\Twill\Services\Forms\Fields\Traits\IsTranslatable;
Expand All @@ -13,6 +14,7 @@ class Radios extends BaseFormField
use HasOptions;
use Inlineable;
use HasBorder;
use HasColumns;

public static function make(): static
{
Expand Down
18 changes: 18 additions & 0 deletions src/Services/Forms/Fields/Traits/HasColumns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace A17\Twill\Services\Forms\Fields\Traits;

trait HasColumns
{
protected int $columns = 0;

/**
* The amount of column to show the option in (when using unpack).
*/
public function columns(int $columns = 1): static
{
$this->columns = $columns;

return $this;
}
}
12 changes: 2 additions & 10 deletions src/Services/Forms/Fields/Traits/Unpackable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

trait Unpackable
{
use HasColumns;

protected bool $unpack = false;

/**
Expand All @@ -15,14 +17,4 @@ public function unpack(bool $unpack = true): static

return $this;
}

/**
* The amount of column to show the option in (when using unpack).
*/
public function columns(int $columns = 1): static
{
$this->columns = $columns;

return $this;
}
}