1
0
Fork 0

Form: adding checkbox component.

This commit is contained in:
Henrik Hautakoski 2021-07-23 17:00:07 +02:00
parent 01b1b06541
commit f9d44de6cb
3 changed files with 29 additions and 0 deletions

View file

@ -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,
];
/**

View 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');
}
}

View file

@ -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