简体   繁体   English

Laravel表单中的HTML表单

[英]HTML Form in Laravel Form

I'm searching for a couple of time for some formulars for Laravel and of course I found a lot. 我正在寻找一些Laravel配方设计师的时间,当然我发现了很多。 But there are still some things I need to change them. 但是,我仍然需要更改某些内容。

This is the orginal form: 这是原始形式:

<form method="POST" action="/auth/login">
    {!! csrf_field() !!}

    <div>
        Email
        <input type="email" name="email" value="{{ old('email') }}">
    </div>

    <div>
        Password
        <input type="password" name="password" id="password">
    </div>

    <div>
        <input type="checkbox" name="remember"> Remember Me
    </div>

    <div>
        <button type="submit">Login</button>
    </div>
</form>

and thats how I changed them: 那就是我如何更改它们:

            {!! Form::open(array('action' => 'Auth\\AuthController@postLogin')) !!}
                Email
                <input type="email" name="email" value="{{ old('email') }}"><br><br>
                Password
                {!! Form::password('password', array('id' => 'password')) !!}<br>
                {!! Form::checkbox('remember') !!} Remember Me
                {!! Form::submit('Login', array('class' => 'btn btn-primary')) !!}
            {{ Form::close() }}

Things I need to change: 我需要改变的事情:

the whole 'email input', with the {{ old('email) }} insite the laravel form. 整个“电子邮件输入”,并在laravel表单中添加{{old('email)}}。

And I don't like to write: Email/Password/Remember me/ outsite of the Form. 而且我不喜欢写:电子邮件/密码/记住我/表格的异地。

Can someone give me this as a laravel form? 有人可以把我当成laravel的形式给我吗?

{!! Form::email('email', old('email', null), ['id' => 'input-id']) !!}

You just need to understand which parameters Form::input() can take Usually 您只需要了解Form::input()可以采用哪些参数,通常

  1. name 名称
  2. value
  3. array for options (like id, class, autocomplete and etc) 选项数组(如id,class,autocomplete等)

Input with placeholder 用占位符输入

{!! Form::email('email', old('email', null), ['placeholder' => old('email','default@email.com')]) !!}

Here I have old('email', null) where is null is default value, you can change it to anything you want, to be shown by defaul if email is empty 这里我有old('email', null) ,其中null为默认值,您可以将其更改为所需的任何内容,如果email为空,则默认显示

Labels
Form::label('email', 'E-Mail Address', ['class'=>'my-class']);

Input 输入项

{!! Form::email('email', old('email')) !!}

or 要么

{!! Form::text('email', old('email')) !!}

Labels 标签

If You want to change these texts into labels You can, for example: 如果要将这些文本更改为标签,则可以,例如:

{!! Form::label('email', 'E-mail') !!} {!! Form::label('email', 'E-mail') !!} instead of E-mail {!! Form::label('email', 'E-mail') !!}而不是E-mail

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM