Resizing checkbox in form group in Laravel - laravel

<div class="col-md-3">
<div class="white-box">
{{ Form::open(['route' => ['resources.select'], 'method' => 'ANY', 'role' => 'select']) }}
<div class="form-group">
{{ Form::label('category_label', 'Categories : ') }}
{{ Form::select('category_select', $category_select, ['class'=>'form-control']) }}
{{ Form::button('Submit',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_resource']) }}
</div>
{{ Form::close() }}
</div>
</div>
This is my code. I have three different divisions that look the same. When I tried to change to a grid view, The select boxes stay overlapping the div block.
I want them to stay within the block in the view.

The reason why your select is overlapping is because you are missing null as a parameter in the declaration.
Change this line;
{{ Form::select('category_select', $category_select, ['class'=>'form-control']) }}
to this;
{{ Form::select('category_select', $category_select, null, ['class'=>'form-control']) }}
Also you do not need the to style the form. A more efficient way of creating the form in your question would be like the example below
<div class="col-md-3">
<div class="white-box">
{{ Form::open(['route' => ['resources.select'], 'method' => 'ANY', 'role' => 'select']) }}
<div class="form-group">
{{ Form::label('category_label', 'Categories : ') }}
{{ Form::select('category_select', $category_select, null, ['class'=>'form-control']) }}
</div>
{{ Form::button('Submit',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_resource']) }}
{{ Form::close() }}
</div>
</div>

Related

Laravel form model attributes

How to pass attributes like id, class to form model?
This what i try not working and in official Laravel documentation wass not defined.
#if(isset($country))
{{ Form::model($country, ['route' => ['country.show', $country->id]], ['class' => "123"]) }}
#else
{{ Form::open(['route' => 'country.store', 'id'=> 'admin_store_form' ]) }}
#endif
<div class="row mb-2">
<div class="col-sm-1">
{{ Form::label('name', 'Name', ['class' => 'col-sm-2 admin-label col-form-label']) }}
</div>
<div class="col-sm-3">
{{ Form::text('name', old('name'), ['placeholder'=>'Name', 'class' => 'form-control form-control-sm admin-control']) }}
</div>
</div>
{{ Form::close() }}
I define 'class' => "123" but that not work.
The correct way to add a class to Form::model is:
{{ Form::model($country, ['route' => ['country.show', $country->id], 'class' => '123']) }}
You need to add the class key to the same array argument as route.

{!! Html::style('css/parsley.css') !!} NOT WORKING

I'm new to Laravel and I also understand that Laravel has stopped supporting Collective but I managed to still install the package into my Laravel 5.8 project.
Now my problem is, when I tried adding the line below, it does not work. When I inspect element, it's not showing in the head section of the page.
{!! Html::style('css/parsley.css') !!}
Do you think it has something to do with the fact that Laravel no longer supports Collective or I'm doing something wrong here?
Thank you so much for your help guys!
I also tried using
<link href="{{ asset('css/parsley.css') }}" rel="stylesheet">
BUT STILL NOT WORKING.
This is the code of the whole page I'm working on.
#extends('main')
#section('title', '| New Post')
#section('stylesheets')
{{-- {!! Html::style('css/parsley.css') !!} --}}
<link href="{{ asset('css/parsley.css') }}" rel="stylesheet">
#endsection
#section('content')
<div class="jumbotron">
<div class="container">
<h1 class="display-4">Create New Post</h1>
<p class="lead"></p>
<hr class="my-4">
<p>Fill out the fields to write your post.</p>
{{-- <a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a> --}}
</div>
</div>
<div class="container">
<div class="col-sm-12 col-md-12">
{!! Form::open(array('route' => 'posts.store', 'data-parsly-validate' => '')) !!}
{{ Form::label('title', 'Title:') }}
{{ Form::text('title', null, array('class' => 'form-control', 'required' => '')) }}
{{ Form::label('body', 'Body:') }}
{{ Form::textarea('body', null, array('class' => 'form-control', 'required' => '')) }}
{{ Form::submit('Create Post', array('class' => 'btn btn-success btn-lg btn-block mt-2')) }}
{!! Form::close() !!}
</div>
</div>
#endsection
#section('scripts')
{!! Html::script('js/parsley.min.js') !!}
#endsection
I expected the parsley.css and parsley.min.js be imported into the page but it didn't work.
How does your template looks like? Do you have a #yield('stylesheets') in your template?
Where is your parsley.css located?
I fixed the problem. I had to remove the Collective codes and back to basic to make it work.

Link Button Not Working in Laravel

I want to edit a record in a CRUD application in laravel where I have a button which has been linked to go to the index view but when I click it, it redirects me to the UPDATE method of the controller.
This is my form:
{!! Form::open(['route' => ['players.update', $player->id], 'method' => 'PUT', 'files'=>'true']) !!}
<div class="row col-md-10 col-md-offset-1 panel">
<div class="col-md-8 col-md-offset-2">
<br />
<div class="form-group">
{{ Form::label('name', 'Player Name') }}
{{ Form::text('name', $player->name, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('file', 'Upload Image') }}
{{ Form::file('pic') }}
</div>
<div class="form-group">
{{Form::button('Save Record', ['type' => 'submit', 'class' => 'btn btn-success'])}}
{!! Form::close() !!}
<a href="{{ route('players.index') }}">
<button class="btn btn-danger" >Cancel</button>
</a>
</div>
</div>
</div>
I have the following button for going back to the index page but this is taking me to the UPDATE method of the controller:
<a href="{{ route('players.index') }}">
<button class="btn btn-danger" >Cancel</button>
</a>
This is my index method in the controller:
public function index()
{
$players = Player::paginate(5);
return view('players.index', compact('players'));
}
This is the UPDATE method in the controller:
public function update(Request $request, $id)
{
return "Hi";
}
This is my route file contents:
Route::resource('news', 'NewsController');
Route::resource('competition', 'CompetitionsController');
Route::resource('players', 'PlayersConroller');
Everything looks fine to me but I don't know what goes wrong here.
Any help is appreciated in advance.
I am not sure if it will solve your issue, try to put your button code outside the form-group div.
You can change your code as
Cancel
You can check your html you have put button inside form tag which of type submit that's why it is submitting the form again.
Replace your form code with:
<div class="row col-md-10 col-md-offset-1 panel">
<div class="col-md-8 col-md-offset-2">
{!! Form::open(['route' => ['players.update', $player->id], 'method' => 'PUT', 'files'=>'true']) !!}
<br />
<div class="form-group">
{{ Form::label('name', 'Player Name') }} {{ Form::text('name', $player->name, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('file', 'Upload Image') }} {{ Form::file('pic') }}
</div>
<div class="form-group">
{{Form::button('Save Record', ['type' => 'submit', 'class' => 'btn btn-success'])}}
</div>
{!! Form::close() !!}
</div>
<a href="{{ route('players.index') }}">
<button class="btn btn-danger">Cancel</button>
</a>
</div>

Why do i have a form url point at thesame location but not at a specific file that will insert my data into database

My LoginUser.blade.php
<h1>Login</h1>
{{-- Form start comment --}}
{{ Form::open(array('url' => 'user/loginUser')) }}
<p>
{{ Form::label('email', 'E-Mail Address') }}
{{ Form::email('email', null, array("placeholder" => "Enter your email")) }}
</p>
<p>
{{ Form::label('password', 'Password') }}
{{ Form::password('password', array("placeholder"=>"Enter your password")) }}
</p>
<p>
{{ Form::submit('Sign In') }}
</p>
{{ Form::close() }}
{{-- Form end comment --}}
So my Question is why should my URL points to my current LoginUser.blade.php which contains the HTML forms?? Please am new to laravel am using laravel 5.2

laravel blade form show me an exception error

First of all sorry for my bad english.
I have a laravel form using blade template engine that show me an exception error. If i remove the code and use the php form with echo statmente everything fine and the page show up.
where is the problem? Here is my code
{{ HTML::ul($errors->all()) }}
{{ Form::open(array('url' => 'news')) }}
<div class="form-group">
{{ Form::label('name', 'Name') }}
{{ Form::title('name', Input::old('title'), array('class' => 'form-control')) }}
</div>
<div class="form-group">
{{ Form::label('email', 'Email') }}
{{ Form::text('email', Input::old('description'), array('class' => 'form-control')) }}
</div>
{{ Form::submit('Create the Nerd!', array('class' => 'btn btn-primary')) }}
{{ Form::close() }}
There is no such thing as Form::title() in laravel.
Try this
{{ HTML::ul($errors->all()) }}
{{ Form::open(array('url' => 'news')) }}
<div class="form-group">
{{ Form::label('name', 'Name') }}
{{ Form::text('name', Input::old('title'), array('class' => 'form-control')) }}
</div>
<div class="form-group">
{{ Form::label('email', 'Email') }}
{{ Form::text('email', Input::old('description'), array('class' => 'form-control')) }}
</div>
{{ Form::submit('Create the Nerd!', array('class' => 'btn btn-primary')) }}
{{ Form::close() }}
Make sure you figure these errors yourself as these are typing mistakes.

Resources