Skip to main content

Forms

Forms are essential elements for interacting with users and are often used to collect information. Forms are used to collect user information such as contact details, comments, reviews, etc. Forms are also used to collect user information such as registration, checkout, etc.

For forms, we have added a set of components as file @include for forms. You can use them in your views. This allows you to easily modify them without having to go through each form. To use them:

Input

@include('shared.input', ['name' => 'name', 'label' => 'Name', 'value' => '', 'type' => 'text'])

PropertyDescriptionTypeRequired
nameField nameStringYes
labelField labelStringNo
valueField valueStringNo
typeField typeStringNo
attributesField attributesArrayNo
stepField stepStringNo
disabledDisabled fieldBoolNo
readonlyReadonly fieldBoolNo
helpField helpStringNo
optionalOptional fieldBoolNo

Password

@include('shared.password', ['name' => 'password', 'label' => 'Password', 'value' => ''])

PropertyDescriptionTypeRequired
nameField nameStringYes
labelField labelStringNo
valueField valueStringNo
helpField helpStringNo
optionalOptional fieldBoolNo

Textarea

@include('shared.textarea', ['name' => 'description', 'label' => 'Description', 'value' => ''])

PropertyDescriptionTypeRequired
nameField nameStringYes
labelField labelStringNo
valueField valueStringNo
attributesField attributesArrayNo
rowsNumber of rowsIntegerNo
disabledDisabled fieldBoolNo
helpField helpStringNo
InverifiedvalueUnverified value (unescaped HTML)StringNo

Select

@include('shared.select', ['name' => 'country', 'label' => 'Country', 'value' => '', 'options' => ['France', 'Belgium', 'Germany']])

PropertyDescriptionTypeRequired
nameField nameStringYes
labelField labelStringNo
valueField valueStringNo
optionsField optionsArrayYes
attributesField attributesArrayNo
helpField helpStringNo

Checkbox

@include('shared.checkbox', ['name' => 'terms', 'label' => 'I agree to the terms and conditions', 'value' => '1'])

PropertyDescriptionTypeRequired
nameField nameStringYes
labelField labelStringNo
valueField valueStringNo
checkedChecked fieldBoolNo

Captcha

If you feel you need a captcha for your form, you can add the captcha using the following component:

@include('shared.captcha')

ClientXCMS will handle the creation and validation of the captcha for you.

Flash Message

ClientXCMS supports flash messages for forms. You can display them using the following component:

@include('shared.flash')

Validation

ClientXCMS supports form validation and displays the error message next to the relevant field. You can check the Laravel documentation for more information on validation. To debug validation errors, you can use Laravel's errors() method or @dump($errors);.

@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif