【问题标题】:Laravel - change formular field border color if $error is trueLaravel - 如果 $error 为真,则更改公式字段边框颜色
【发布时间】:2016-08-17 07:42:24
【问题描述】:

我有一个公式,如果发生 $error,我希望边框颜色变为红色。

例如这个字段:

{!! Form::text('name1', old('name1', null), ['class' => 'form-control error', 'placeholder' => ' Your first name']) !!}
{!! $errors->first('name1','<span class="help-block error-text-color">:message</span>') !!}

我的css:

.error 
{
    border: 1px solid red;
}

我希望如果 name1 字段存在 $error,则执行 .error 类 css。如果没有任何 $error,则表单可以保持原样,而无需 .error 类。

现在有人知道我该怎么做吗?

【问题讨论】:

标签: php html css laravel


【解决方案1】:

试试这个

 {!! Form::text('name1', old('name1', null), ['class' => 'form-control' . $errors->first('name1', ' error'), 'placeholder' => ' Your first name']) !!}

【讨论】:

    【解决方案2】:

    我更新了我的帖子。忘记了你的 CSS 类名。再试一次

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-14
      • 1970-01-01
      • 2021-11-20
      • 1970-01-01
      • 1970-01-01
      • 2013-07-23
      • 2014-06-12
      • 2013-02-15
      相关资源
      最近更新 更多