LaravelCollective / docs

Documentation for LaravelCollective Packages
158 stars 103 forks source link

Materialize form with laravel #27

Closed Luizgpp closed 8 years ago

Luizgpp commented 8 years ago

How i can use this submit button with laravel using form.

Materializecss: http://materializecss.com/buttons.html

 <button class="btn waves-effect waves-light" type="submit" name="action">Submit
    <i class="material-icons right">send</i>
  </button>
Form::submit('Submit',array('class'=>'btn waves-effect waves-light');
 <i class="material-icons right">send</i>

This not working.

alexanderawitin commented 8 years ago

+1

redgluten commented 8 years ago

If you want to put HTML inside your button you can’t use this helper but you can still the regular HTML button with the other helpers.

alexanderawitin commented 8 years ago

I know that I can use regular HTML on forms. I've tried it. But, it doesn't work with Form Model Binding.

redgluten commented 8 years ago

But you can mix the two so just use the helpers for the inputs and HTML for the button. Form model binding has no influence on submit button unless I’m missing something?

alexanderawitin commented 8 years ago

What do you mean by mixing the two? How would I do that? Can you provide some examples?

redgluten commented 8 years ago

Let’s say you have a text field named content that you’re going to use with Form-model binding but you still want to create that submit button with HTML inside. You just use the Form helper for the text field and regular HTML for the button.

{!! Form::model($model, ['method' => 'POST', 'route' => 'your route'] !!}

    {!! Form::label('content', 'Content') !!}
    {!! Form::text('content', null) !!}

    <button class="btn waves-effect waves-light" type="submit" name="action">Submit
        <i class="material-icons right">send</i>
    </button>

{!! Form::close() !!}
ghost commented 8 years ago

I am currently trying to migrate a project from bootstrap to Materialize. Unfortunately the registration form is not working in materialize. When I try to register a new user, I can create 1 user and hash the password but the name, username and email fields are not being received by the request. They submit as null. Here is a sample of my code. The other fields are basically the same to avoid repetition.

@extends('layouts.app')
@section('content')
<div class="row">  
    <form method="POST" action="{{ url('/register') }}"
    {{ csrf_field() }}
    <div class="row">
          <div class="input-field col s12">
          <input id="name" type="text" placeholder="Your full name" class="" value="{{ old('name') }}">
         <label for="name">Name</label>
    </div>
alexanderawitin commented 8 years ago

Maybe that is because you don't have a name property/attribute on your text field?

@extends('layouts.app')
@section('content')
<div class="row">  
    <form method="POST" action="{{ url('/register') }}"
    {{ csrf_field() }}
    <div class="row">
          <div class="input-field col s12">
          <input id="name" name="name" type="text" placeholder="Your full name" class="" value="{{ old('name') }}">
         <label for="name">Name</label>
    </div>
 </div>