【问题标题】:How can I add HTML to Form of Laravel?如何将 HTML 添加到 Laravel 的表单中?
【发布时间】:2017-07-16 02:53:42
【问题描述】:

这是我在 Laravel 中的表单:

{!! Form::open($user_id,['method'=>'PATCH','action'=>['changePasswordController@change',$user_id]]) !!}
    <div class="form-group">
        {!! Form::label('current_password',"current password:") !!}
        {!! Form::input('password', 'current_password', null, ['class' => 'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('new_password',"new password:") !!}
        {!! Form::input('password', 'new_password', null, ['class' => 'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::label('re_new_password',"re-new password") !!}
        {!! Form::input('password', 're_new_password', null, ['class' => 'form-control']) !!}
    </div>
    <div class="form-group">
        {!! Form::submit('submit', ['class' => 'btn btn-primary form-control']) !!}
    </div>
    @include('errors.list')

{!! Form::close() !!}

现在我想在这些标签的开头添加这个 HTML:

// which says filling this field is mandatory 
<span style="color:red">*</span>

我该怎么做?

【问题讨论】:

  • 你总是可以使用 CSS label:before 伪元素。

标签: php html forms laravel


【解决方案1】:

最好的方法是将 CSS 放入 CSS 文件并使用 class.然后只需在标签后添加 HTML:

{!! Form::label('current_password',"current password:") !!}
<span class="red">*</span>
{!! Form::input('password', 'current_password', null, ['class' => 'form-control']) !!}

【讨论】:

    猜你喜欢
    • 2018-10-08
    • 1970-01-01
    • 2015-02-04
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-02
    • 2014-05-30
    相关资源
    最近更新 更多