I have from:
{{ Form::open(array('url' => 'announcements', 'class' => 'form-inline', 'method' => 'GET')) }}
And checkbox in form:
{{Form::checkbox('only_subscriptions', '1', old('only_subscriptions'))}}
After submit I get empty old():
old('only_subscriptions')
You would use ->withInput() in redirect(), not in view().
Related
I installed Bagisto and everything run smoothly until I added Laravel AliExpress Dropshipping.
There's error :
Webkul\Ui\Exceptions\ActionKeyException
Missing Keys: title (View: /Applications/MAMP/htdocs/bagisto/packages/Webkul/Dropship/src/Resources/views/admin/products/index.blade.php)
What does Missing Keys: title means
#extends('admin::layouts.content')
#section('page_title')
{{ __('dropship::app.admin.products.title') }}
#stop
#section('content')
<h1>
{{ __('dropship::app.admin.products.title') }}
</h1>
<div class="page-action">
<button class="btn btn-lg btn-primary" style="display: none">
{{ __('dropship::app.admin.products.import-btn-title') }}
</button>
</div>
I had a similar problem with Bagisto Bulk Upload extension. To fix it I added the 'title' key to both addAction at extension's DataGrid class.
public function prepareActions() {
$this->addAction([
'type' => 'Edit',
'method' => 'GET', // use GET request only for redirect purposes
'route' => 'marketplace.bulkupload.profile.edit',
'icon' => 'icon pencil-lg-icon',
'title' => ''
]);
$this->addAction([
'type' => 'Delete',
'method' => 'GET', // use GET request only for redirect purposes
'route' => 'marketplace.bulkupload.profile.delete',
'icon' => 'icon trash-icon',
'title' => ''
]);
$this->enableAction = true;
}
Source
We can send the values of text as follows in laravel collectives? Is it possible to send the value of a button in laravel collecctives?
{{Form::text('element_id','',['class'=>'form-control'])}}
May the following will do the trick
{{ Form::button('Delete', array('class' => 'btn btn-danger delete', 'type' => 'button', 'value' => 'the value')) }}
I am making a multiple inputs search query and i need help cause i do not know how to exactly to do this i have read all the documentation and i did not understand it.Now i am stuck in the controller.....
Also i would really appreciate of how to call the informations that i want in in the show.blade ! Thank you for any help !
Index blade
<div class="panel-body">
<div class="form-group">
<div><h4></h4></div>
<div class="form-group col-md-4">
{{ Form::open(array('action' => array('UserController#search'), 'class'=>'form width88', 'role'=>'search', 'method' => 'GET')) }}
<div id="prefetch">
{{ Form::text('name', null, array('class' => 'typeahead form-group form-control', 'placeholder' => 'name...')) }}
{{ Form::text('lastname', null, array('class' => 'form-group form-control', 'placeholder' => 'lastname...')) }}
{{-- {{ Form::text('id', null, array('class' => 'form-group form-control', 'placeholder' => 'id...')) }}
{{ Form::text('user-seminars', null, array('class' => 'form-group form-control', 'placeholder' => 'Class tha is enrolled...')) }}
{{ Form::text('user-class', null, array('class' => 'form-group form-control', 'placeholder' => 'Class that belongs...')) }}
{{ Form::text('user-annex', null, array('class' => 'form-group form-control', 'placeholder' => 'Department that belongs...')) }}
{{ Form::text('type', null, array('class' => 'form-group form-control', 'placeholder' => 'User type...')) }}
{{ Form::text('date_created', null, array('class' => 'form-group form-control', 'placeholder' => 'date created account...')) }}
{{ Form::text('date_enrolled', null, array('class' => 'form-group form-control', 'placeholder' => 'date enrolled in class...')) }}
routes
Route::get('users/index', 'UserController#index');
Route::get('users/search', 'UserController#search');
Route::get('users/show', 'UserController#show');
UserContoller
public function index(){
return View::make('user.index');
}
public function search(){
return View::make('user.show');
}
public function show(){
return View::make('user.show');
}
USERS TABLE
id , firstname,last_name,etc etc etc
public function search(Request $request){
$users = App\User::where('firstname',$request->name)
->orWhere('lastname',$request->lastname)
->orWhere('id',$request->id)
// more orWhere Clause
->get();
return View::make('user.show',compact('users'));
}
public function show($id){
$user = App\User::find($id);
return View::make('user.show',compact('user'));
}
Why are you using return View::make('user.show') to render two different resources?
the first thing i see its the form action
your code
{{ Form::open(array('action' => array('UserController#search'), 'class'=>'form width88', 'role'=>'search', 'method' => 'GET')) }}
should be
{{ Form::open(array('action' => array('users/search'), 'class'=>'form width88', 'role'=>'search', 'method' => 'GET')) }}
the controller is the fun part. if you're looking for all the inputs to be required you should validate it first
//first we set the inputs rultes
$data = Input::all();
$rules = array(
'name' => 'required',
'lastname' => 'required',
//rest of the inputs that are required
);
//then we use the validator method
$val = Validator::make($data,$rules);
if($val->fails())
{
/*redirect to the form again, you can set errors with session
or ->withError($validator)*/
return Redirect::back();
}
then you make your query
$user = User::where('name','=',$data['name'])
->where('lastname','=',$data['lastname'])
//more where('field','=','value')
->get();
if the fields arent required you only make the query with
$user = User::where('name','=',$data['name'])
->orWhere('lastname','=',$data['lastname'])
//more orWhere('field','=','value')
->get();
and finally you return your result to the view like:
return View::make('user.show')->with('user',$user);
I know that to insert a attribute in forms in laravel we do something like below
{{ Form::open(array('url' => 'comment', 'method' => 'post')) }}
But what i want to do is insert a attribute like this and not in commas
<form data-abide>
Because I'm using foundation as a front end framework so need to use its validation.
You can add it similar way you add method :
{{ Form::open(array('url' => 'comment', 'method' => 'post', 'data-abide' => 'formclass', 'onSubmit' => 'return false;')) }}
This is My View code When i am executing the application it only returns me NULL value, basically my $office_category is not being passed, i need the office category to query the database
<div class="box-body">
{{ Form::open(['route' => 'office.index','class' => 'form-horizontal office-form']) }}
<div class="form-body">
<div class="form-group">
<div class="col-md-3">
{{ Form::select('office_category', [
null=>'Please Select',
'Software' => 'Software',
'Computer Hardware' => 'Computer Hardware',
'Survey Instruments' => 'Survey Instruments',
'Office Equipments' => 'Office Equipments'
], isset($office_category) ? $office_category : '', ['class' => 'form-control input-xlarge select2me', 'placeholder' => 'Project Type', 'id' => 'office_category'] ) }}
</div>
{{ Form::hidden('office_category', $office_category) }}
{{ Form::submit('Search Equipment',['class' => 'btn green']) }}
</div>
</div>
{{ Form::close() }}
My Controller Code: I want the Office category thats it
Class OfficeController extends BaseController{
public function index(){
$office_category = Input::get('office_category');
if($office_category=='')
$offices = Office::orderBy('office_category', 'asc')
->get();
else
$offices = Office::where('office_category','=',$office_category)
->get();
$assets = ['table','datepicker'];
$users = User::where('client_id','=','')
->orderBy('name','asc')
->lists('name','username');
return View::make('office.index',[
'office_category' => $office_category,
'offices' => $offices,
'users' => $users,
'assets' => $assets
]);
}
Where am i going wrong please help.
You have a hidden field directly after your select that has the same name as the select. The value of this hidden field (empty) is what is getting sent to the server.
Delete this line:
{{ Form::hidden('office_category', $office_category) }}
Or rename this hidden field.
By default Form::open creates a POST request and your index method on Controller are expecting a GET request.
You need to add a new route on routes.php to match this POST request.
Route::post('index', 'OfficeController#index');
Or if you don't mind, you can set index to listen any kind of request:
Route::any('index', 'OfficeController#index');
In most of the case, above answer will solve your problem. If not, you can inspect your web request from browser and confirm value in $office_category variable.