Validation

Override auto generated field rules

protected function rules(): array
{
    return array_merge(
        $this->fieldRules(), 
        [ //your custom rules here ]
    );
}

Override auto generated field validation attributes

protected function validationAttributes(): array
{
    return array_merge(
        $this->fieldValidationAttributes(), 
        [ //your custom field validation attributes here ]
    );
}

Form validation settings

// config/tall-forms
'form' => [
    'labelsAsAttributes' => true, //use field labels as validation :attribute
    'notifyErrors' => true, //display notification errors as popups, not just text
]

// override in component
protected function formAttr(): array
{
    return [
        'labelsAsAttributes' => true,
        'notifyErrors' => true,
    ]
}

Field validation methods

Fields are automatically validated when the form is submitted. (If you extend the TALL-form component.)

Field real-time validation methods

You can disable/enable automatic real-time validation with different field methods, depending on the field type. Defaults are set in config/tall-forms field-attributes

Examples

Validation rules precedence

Read more about updatedFooValidate() on the lifecycle hooks page.

Field error message example

Field validation attribute example

Conditional rule example

Component $rules combined with field->rules(), example

Some fields of array type apply field rules to each item in the array. If you want a rule that applies to the array instance you have to add it manually using Livewire default $rules property or rules() method.

Last updated

Was this helpful?