1) Making CRUD so wanted to use yield in value in Form:text to load the values
{!! Form::Text('employeeName_txt',
'#yield('editEmployeeName')',
array('class' => 'form-control','placeholder'=>'Employee Name')) !!}
Getting error
FatalErrorException in 2168be22f5078758fb418696bf6815fc3ab642a4.php line 59:
syntax error, unexpected 'editEmployeeName' (T_STRING)
Can anyone please help what is wrong in this
& also
2) Which is the best method for CRUD
Creating Edit page differently & extending it with create page and yield or section the values
Or in create page only, with the use of if else condition do the coding eg: if route name contains edit then method= put ,delete button show etc.
Try using this
{!! Form::Text('employeeName_txt',"yield('editEmployeeName')", array('class' => 'form-control','placeholder'=>'Employee Name')) !!}
Related
I have the MethodNotAllowedHttpException error when I try to update a data
I try to change the Form::model route to PUT and PATCH
Here's my form::model:
{!! Form::model($mission, ['route' => ['missions.update', $mission->id_missions], 'method' => 'PUT', 'class' => 'form-horizontal panel']) !!}
And here's my route:
Route::resource('missions', 'MissionsController');
I got the error mentionned above
Can somebody help me please ?
Maybe you forgot to spoof the PUT method in your form, you can do that by using blade's #method('PUT').
This is how you can implement it :
<form action="/foo/bar" method="POST">
#method('PUT')
</form>
So try also changing the form's method to POST when you use the Form::model helper because HTML forms can only be sent by GET or POST methods hence why one has to spoof the other CRUD methods.
You can read more about that here.
I have this code:
#include('admin.members.members_form', ['submitButtonText' => '__('member.edit')'])
and in the admin.members.members_form:
{!! Form::submit($submitButtonText, ['class' => '"btn btn-primary"']) !!}
THe inclusion is not working (with this version I have an error with single quote, I tryied with \'member.edit\' have no error but whe button with text __('member.edit')
you can do like that (without quote)
#include('admin.members.members_form', ['submitButtonText' => __('member.edit')])
I have created a blade (using Laravel Collective) with a multipe checkboxes:
#foreach($subsc as $subsc)
<div>
{{Form::checkbox('checkbox['. $subsc->Scheme->Scheme_id .']', '1')}}
{!! Form::label('SchemeName', $subsc->Scheme->Scheme_Name.$subsc->Scheme->Scheme_id, ['class' => 'control-label']) !!}
</div>
#endforeach
Now I want to save each checked box in a table as the scheme_id. How do I do that?
I guess you could use an array as name to make it easier and try something like this.
Form::checkbox('schemeIDS[]', $subsc->Scheme->Scheme_id, true);
// Parameters checkbox: name, value, checked
In the controller function use
$schemeIDS = $request->get('schemeIDS'); // get all the checked values as array
foreach($schemeIDS as $schemeID)
{
// insert into the database
}
Im trying to create DELETE button in my Laravel CRUD app. and have an error:
(2/2) ErrorException array_key_exists(): The first argument should be either a string or an integer
My view:
{{!!Form::open(['action' => ['CompanyController#update', $company->id], 'method' => 'PUT'])!!}}
{{Form::input('Delete',['class'=>'btn btn-danger'])}}
{{!!Form::close()!!}}
I'm using Laravel Collective documentation and it says I can use:
Form::open(['action' => ['Controller#method', $user]])
But whats wrong with my code?
You must provide the key. Collective won't try to guess the key name, as we are used to on Laravel.
Form::open(['action' => ['Controller#method', $user->id]])
The piece of code above shows how to provide the key: $user->id
I have a strange problem today because the code that I will show you is to upload and move an image in a database + uploads directory in my laravel.
The last projects worked but today with laravel 5.4 the code doesn't work anymore and when I want to upload a new image I get an exception
with this line:
Call to a member function getClientOriginalName() on null
Line : $licencie_structure->lb_photo = $request->file('lb_photo')->getClientOriginalName();
Here my blade line to upload the file :
<div class="form-group">
<label>Select a picture : </label>
{!! Form::file('lb_photo' , ['class' => 'form-control', 'placeholder' => 'Photo']) !!}
</div>
Does someone have an idea why I get an exception : Call to a member function getClientOriginalName() on null?
Thanks a lot in advance friends!
This is returning null, meaning it's not in the request object.
$request->file('lb_photo')
Is this form actually sending the upload? Did you forget to add enctype='multipart/form-data' to the form? Is the name correct?
Check the output of $request->all().