mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 01:58:00 +08:00
New checkboxes fieldtype
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<ol>
|
||||
@foreach ($options as $option)
|
||||
<li>
|
||||
{{ $option->render() }}
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@@ -1,5 +1,5 @@
|
||||
<fieldset class="border rounded border-grey-100 p-4 md:px-6">
|
||||
<legend class="text-sm leading-tight font-semibold cursor-pointer px-2">
|
||||
<legend class="text-sm leading-tight font-semibold px-2">
|
||||
{{ __($legend) }}
|
||||
</legend>
|
||||
<x-filament::fields :fields="$fields" :class="$class" />
|
||||
|
||||
@@ -5,9 +5,34 @@ namespace Filament\Fields;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BaseField {
|
||||
public $model;
|
||||
public $id;
|
||||
protected $enabled = true;
|
||||
protected $view;
|
||||
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->id = Str::slug($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function make(string $model): self
|
||||
{
|
||||
return new static($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function id($id): self
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Fields;
|
||||
|
||||
use Filament\Fields\Checkbox;
|
||||
|
||||
class Checkboxes extends BaseField {
|
||||
public $options = [];
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function options(array $options): self
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
$this->options[] = Checkbox::make($this->model.'.'.$key)->label($value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -3,27 +3,12 @@
|
||||
namespace Filament\Fields;
|
||||
|
||||
class Field extends BaseField {
|
||||
public $model;
|
||||
public $modelDirective = 'wire:model.defer';
|
||||
public $value;
|
||||
public $id;
|
||||
public $label;
|
||||
public $hint;
|
||||
public $help;
|
||||
public $extraAttributes = [];
|
||||
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $this->id = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function make(string $model): self
|
||||
{
|
||||
return new static($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
@@ -43,15 +28,6 @@ class Field extends BaseField {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function id($id): self
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user