I am using following codes for login form -
{!! Form::open(['url' => '/admin/login']) !!}
<div class="form-group">
{!! Form::label('email', 'Email Id:') !!}
{!! Form::text('email', null, ['class' => 'form-control input-sm']) !!}
</div>
<div class="form-group">
{!! Form::label('password', 'Password') !!}
{!! Form::password('password', ['class' => 'form-control input-sm']) !!}
</div>
<div class="form-group">
{!! csrf_field() !!}
{!! Form::submit('Login', ['class' => 'btn btn-primary btn-block']) !!}
</div>
{!! Form::close() !!}
But when I inspect it in browser , it is showing input field with name="_token" but with empty value.
Is there anything else I am missing? Please guide.
Related
Here is my code:
controller file: EmergencyContactsController.php
$surnames = DB::table('salutations')->pluck('name');
return view('patient/emergencycontacts', ['salutation' => $surnames]);
Blade file: patient/emergencycontacts.blade.php
{!! Form::open(array('route' => 'emergencycontacts_store', 'class' => 'form')) !!}
<div class="form-group">
{!! Form::label('Salutation') !!}
{{ Form::select('role', ['' => 'Select Role'] + $salutation, null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{!! Form::label('First Name') !!}
{!! Form::text('firstname', null, array('required', 'class'=>'form-control', 'placeholder'=>'First Name')) !!}
</div>
<div class="form-group">
{!! Form::label('Last Name') !!}
{!! Form::text('lastname', null, array('required', 'class'=>'form-control', 'placeholder'=>'Last Name')) !!}
</div>
<div class="form-group">
{!! Form::label('Relationship') !!}
{{ Form::select('relationship', ['Father', 'Mother', 'Husband','Wife','Son','Daughter','Uncle','Aunty','Other']) }}
</div>
<div class="form-group">
{!! Form::label('Phone') !!}
{!! Form::text('phone', null, array('required', 'class'=>'form-control', 'placeholder'=>'Phone')) !!}
</div>
<div class="form-group">
{!! Form::label('Fax') !!}
{!! Form::text('fax', null, array('class'=>'form-control', 'placeholder'=>'Fax')) !!}
</div>
<div class="form-group">
{!! Form::submit('Save',array('class'=>'btn btn-primary')) !!}
</div>
{{ Form::close() }}
When I go to url http://localhost:8000/patient/emergency-contacts/create it gives me error:
"Unsupported operand types"
You need to change 2 things
In your controller:
$surnames = DB::table('salutations')->pluck('name', 'id')->toArray();
So you get an array as [id => 'value'] and not only ['value']. In the View:
{!! Form::select('role', $salutation, null, ['class' => 'form-control']) !!}
{!! Form::select('relationship', ['Father', 'Mother', 'Husband','Wife','Son','Daughter','Uncle','Aunty','Other']) !!}
{!! Form::close() !!}
Always 'escape' the Form tags, if not, the HTML will be printed on screen, not parsed.
please use view('patient.emergencycontacts', ['salutation' => $surnames]);
ErrorException in FormBuilder.php line 1208:
Method lable does not exist.
i am using laravel 5.2 there it shows this error , i have searched many sites , but i have not what i needed . can any one help me
below is my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update</title>
</head>
<body>
// {!! Form::open([ 'routes' => 'testing.update' ]) !!}
// {{ Form::model($user,['method'=>'patch','action'=>['testing#update',$user->id]])}}
// <div class="form-group">
// {!! Form::label('name', 'Name:', ['class' => 'control-label']) !!}
// {!! Form::text('name', null, ['class' => 'form-control']) !!}
// </div>
// <div class="form-group">
// {!! Form::label('email', 'Email:', ['class' => 'control-label']) !!}
// {!! Form::text('email', null, ['class' => 'form-control']) !!}
// </div>
// <div class="form-group">
// {!! Form::label('mobile', 'Mobile:', ['class' => 'control-label']) !!}
// {!! Form::text('mobile', null, ['class' => 'form-control']) !!}
// </div>
// {!! Form::submit('Update', ['class' => 'btn btn-primary']) !!}
// {!! Form::close() !!}
{{ Form::open([ 'routes' => 'testing.update' ]) }}
{{ Form::model($user,['method'=>'patch','action'=>['testing#update',$user->id]])}}
{{ Form::lable('name','Name')}}
{{ Form::text('name')}}
{{ Form::lable('email','email')}}
{{ Form::text('email')}}
{{ Form::lable('mobile','mobile')}}
{{ Form::text('mobile')}}
<br/>
{{ Form::submit("update")}}u {{ Form::close()}}
</body>
</html>
here i used both 4.5 and 5.2 version format
I have a test set up like this
use WithoutMiddleware;
public function test_it_submits_forms()
{
$this->visit('/admin/menu/samples')
->click('New Sample')
->seePageIs('/admin/menu/samples/new/create')
->type('test1', 'name')
->type('test2','description')
->type('test2','introduction')
->select(11, 'scenario_id')
->type('test','slug')
->press('Add');
}
and the file I am testing like this.
{!! Form::open(['url' => 'admin/menu/samples/', 'method' => 'POST']) !!}
<div class="row"><div class="form-group col-xs-8 col-md-7 {!! $errors->has('name') ? 'has-
error' : '' !!}">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null,['class' => 'form-control']) !!}
{!! $errors->first('name', '<span class="help-block">:message</span>')!!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('introduction', 'Introduction:') !!}
{!! Form::textarea('introduction',null, ['class' => 'form-control']) !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('description', 'Description:') !!}
{!! Form::textarea('description',null, ['class' => 'form-control']) !!}
</div>
<div class="form-group col-xs-8 col-md-7 {!! $errors->has('slug') ? 'has-error' : '' !!}">
{!! Form::label('slug', 'URL:') !!}
{!! Form::text('slug',null, ['class' => 'form-control']) !!}
{!! $errors->first('slug', '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('available_from', 'Available from:') !!}
{!! Form::date('available_from', \Carbon\Carbon::now(), ['class' => 'form-control2']) !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('available_until', 'Available until:') !!}
{!! Form::date('available_until', \Carbon\Carbon::now(), ['class' => 'form-control2']) !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('needs_auth', 'Needs authentication:') !!}
{!! Form::checkbox('needs_auth', 'value', false) !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('is_active', 'Active:') !!}
{!! Form::checkbox('is_active', 'value', false) !!}
</div>
<div class="form-group col-xs-8 col-md-7">
<h3>Add a scenario</h3>
{!! Form::select('scenario_id',($scenario), null,
['id'=>'scenario_id','placeholder' => 'Select one...']) !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::submit('Add', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
The test throws undefined variable errors on both of the variables $errors in form elements name and slug ( they just light up the form if something is not filled properly).
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined varia...', '/home/vagrant/C...', 9, Array)
Could anyone tell why and how to fix this? The $errors variable should always be there by Laravel standards...
The $errors variable should always be there by Laravel standards...
Unless you disable the middleware!
The feature is implemented by having the ShareErrorsFromSession being enabled; which you just disabled.
The answer at Temporarily disable / bypass Middleware has some pointers form here on.
I have a problem using #yield from one view to another. I couldn't get anything from my question.blade.php file, even if using just a simple text.
My create.blade.php file:
#extends('layout/layoutAdmin')
#section('content')
<div class="container">
<h1>Add a new inventory</h1>
{!! Form::open(['url' => 'admin/menu/inventories/', 'method' => 'POST']) !!}
<div class="row">
<div class="form-group col-xs-8 col-md-7 {!! $errors->has('text') ? 'has-error' : '' !!}">
{!! Form::label('text', 'Name:') !!}
{!! Form::text('text', null,['class' => 'form-control']) !!}
{!! $errors->first('text', '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('description', 'Description:') !!}
{!! Form::textarea('description', null, ['class' => 'form-control']) !!}
</div>
#yield('content2')
</div>
</div>
{!! Form::close() !!}
#stop
And my question.blade.php file:
#extends('inventory.create')
#section('content2')
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('type', 'Type:') !!}
{!! Form::number('type', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group col-xs-8 col-md-7 {!! $errors->has('introduction') ? 'has-error' : '' !!}">
{!! Form::label('introduction', 'Introductory Text:') !!}
{!! Form::textarea('introduction', null, ['class' => 'form-control']) !!}
{!! $errors->first('introduction', '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('value', 'Values:') !!}
{!! Form::textarea('value', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group col-xs-8 col-md-7 {!! $errors->has('language') ? 'has-error' : '' !!}">
{!! Form::label('language', 'Language:') !!}
{!! Form::text('language', null, ['class' => 'form-control']) !!}
{!! $errors->first('language', '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group col-xs-8 col-md-7">
{!! Form::label('is_active', 'Active:') !!}
{!! Form::checkbox('is_active', null, ['class' => 'form-control']) !!}
</div>
#stop
My QuestionController:
public function create()
{
return view('inventory.question');
}
Route:
Route::get('admin/menu/inventories/new/question', 'QuestionController#create');
Edit: fixed the typo
You are yielding to a section called container2 and you have placed your content in a section called content2.
I'm learning how to use Laravel. I just learned how to do a foreach loop in my database for articles. Now I want to try the same but loop for all the images in my image directory. How can I do this? Is it similar to this :
#foreach (File::allFiles(public_path().'/assets/image/') as $file)
{
$filename = $file->getRelativePathName();
echo HTML::image('public/assets/img/'.$filename, $filename);
}
#endforeach
also in my article page I was able to apply the foreach to a li object, how can I do the same for my images?
#foreach($articles as $article)
<div class="grid-item">
<li>{{$article->photo}}</li>
<li>{{$article->title}}</li>
{!! Form::open(['url' => 'article' ]) !!}
{!! Form::file('image', null) !!}
<div class="form-group">
{!! Form::hidden('user_id', $article->user_id, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Like', ['class' => 'btn btn-primary form-control']) !!}
</div>
</div>
{!! Form::close() !!}
<!--{!! Form::open(['url' => 'article' ]) !!}
<div class="form-group">
{!! Form::submit('like', ['class' => 'btn btn-primary form-control']) !!}
</div>
{!! Form::close() !!}
<img href="#popup" data-toggle="modal" class="grid-item1" src="/assets/image/article/thumbnail/{{$article->photo}}">
-->
#endforeach