[英]How can I add a shorthand if statement in blade, laravel?
How can I add a shorthand if statement in blade, laravel, that adds a class to my bootstrap form input of 'alert-danger', that gives it a red border/outline when doing form validation? 如何在刀片laravel中添加if语句的速记if语句,该语句在我的引导程序表单输入中添加了一个类'alert-danger',在进行表单验证时为它提供了红色边框/轮廓? Basically I want to check if there is a form error and if there is I want the input to have a red outline.
基本上,我想检查是否存在表单错误,是否要输入红色轮廓。
This is what I have but the class of 'alert-danger' is not being applied: 这就是我所拥有的,但是没有应用“警告危险”类:
<div class="form-group">
{!! Form::label('email', 'Email:') !!}
{!! Form::email('email', null, ['class'=>'form-control'], $errors->first('email') ? ['class'=>'alert-danger'] : '') !!}
</div>
Please keep in mind I'm fairly new to Laravel and Blade. 请记住,我是Laravel和Blade的新手。 Thank you for your help!
谢谢您的帮助!
您可以尝试这样的事情
{!! Form::email('email', null, ['class'=> $errors->first('email') ? 'alert-danger form-control' : 'form-control']) !!}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.