Form: adding checkbox component.
This commit is contained in:
parent
01b1b06541
commit
f9d44de6cb
3 changed files with 29 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ class BladeServiceProvider extends ServiceProvider
|
|||
'input-password' => \App\View\Components\Form\Password::class,
|
||||
'textarea' => \App\View\Components\Form\Textarea::class,
|
||||
'select' => \App\View\Components\Form\Select::class,
|
||||
'checkbox' => \App\View\Components\Form\Checkbox::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
21
app/View/Components/Form/Checkbox.php
Normal file
21
app/View/Components/Form/Checkbox.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\View\Components\Form;
|
||||
|
||||
class Checkbox extends Input
|
||||
{
|
||||
public function __construct($name, ?string $id = null, ?string $value = null, bool $disabled = false)
|
||||
{
|
||||
parent::__construct($name, $id, 'checkbox', $value, $disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Closure|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.inputs.checkbox');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
<input type="checkbox" name="{{ $name }}" value="{{ $value }}"
|
||||
{{ $attributes->merge(['class' => ($errors->has($name) ? 'border-danger-400 text-danger-400 ' : '') . 'border border-gray-200 rounded p-2 focus:ring-1']) }} {{ $disabled }} />
|
||||
|
||||
@error($name)
|
||||
<p class="ml-2 text-danger-400 text-sm">{{ $message }}</p>
|
||||
@enderror
|
||||
Loading…
Add table
Add a link
Reference in a new issue