ItzMe488
ItzMe488

Reputation: 191

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. 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.

And I don't like to write: Email/Password/Remember me/ outsite of the Form.

Can someone give me this as a laravel form?

Upvotes: 1

Views: 2090

Answers (2)

D. Cichowski
D. Cichowski

Reputation: 777

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') !!} instead of E-mail

Upvotes: 1

SergkeiM
SergkeiM

Reputation: 4168

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

You just need to understand which parameters Form::input() can take Usually

  1. name
  2. value
  3. array for options (like id, class, autocomplete and etc)

Input with placeholder

{!! Form::email('email', old('email', null), ['placeholder' => old('email','[email protected]')]) !!}

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

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

Upvotes: 4

Related Questions