php - Laravel/Blade: How to style error message in form -


i made form validation (laravel blade template engine) , works expected.

here's code:

@if ($errors->first('email'))   {{ form::text('email', null, $attributes = array('class'=>'error')) }}   {{ $errors->first('email', '<small class=error>:message</small>') }} @else   {{ form::text('email') }} @endif 

is there cleaner solution?

i'd write form::text('email') once...

this should self-explanatory

{{ form::text('email', null, $attributes = $errors->has('email') ? array('class'=>'error') : array()) }} @if ($errors->has('email'))     {{ $errors->first('email', '<small class=error>:message</small>') }} @endif 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -