Retrieve Errors

Methods

has()

Check if a field has a validation error. This can be useful to display error states.

1
has ( $field = null )

Parameter Type Default Description
$field string null Name of the field
@return bool

Examples

Basic:

1
2
3
<?php

$form->errors()->has('email');

Conditional:

1
2
3
4
5
6
7
<?php
$errors = $form->errors();
?>

<div class="<?php echo ( $errors->has('email') ) ? 'error' : ''">
  <input name="email" type="text">
</div>


first()

Get the first error message for a given field.

This is useful for displaying inline error messages.

1
first( $field )

Parameter Type Default Description
$field string Name of the field
@return string

Examples

Basic:

1
2
3
<?php

echo $form->errors()->first('email');

In a template:

1
2
3
4
<div>
  <input name="email" type="text">
  <small class="error"><?php echo $form->errors()->first('email'); ?></small>
</div>