I am looking for a way to add customization to laravel form,instead of using type form
How can I get the following,
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-append">
<span class="input-group-text"><i
class="livicon" data-name="number"
data-size="18" data-c="#000"
data-hc="#000" data-loop="true"></i></span>
</span>
<input type="number" class="form-control"
placeholder="Warehouse No" id="wh_no" name="wh_no" >
</div>
out from laravel forms,this don't load livicion or font-awesome,,ve
{!! Form::number('wh_no', null, ['class' => 'form-control','class'=>'livicon','data-name'=>'user']) !!}
like this
Related
I have a search box and when I enter the code in that search box it should show the required data on the web page. but I'm unable to fetch data by using the search box. because I am unable to send that code to my controller which is entered in the search box.
As well as when I am submitting the code in the search box the browser URL should replace that code (It is like an edit function)
So, can someone help me to get it done? The following code shows what I have done.
Thank You, everyone!
{!! Form::open(['action' => ['Account\CodeController#codeResult', 'code'=> 'code'], 'method' => 'get' , 'class'=>"col12"]) !!}
<div class="row mb-5">
<div class="col-4 mx-auto">
<div class="text-input-with-icon">
<span class="fa fa-search form-control-feedback float-right"></span>
<input type="text" name="search" value="" id="barcode" placeholder="Search By code">
</div>
</div>
<div class="col-2 mx-auto">
<button type="submit" name="code" value="name" class="btn btn-reset">SEARCH
</button>
</div>
</div>
{!! Form::close() !!}
I'm trying to populate data into input values from mysql database so that I can see and change the data.
I have a form named form.blade.php which will be included in both create.blade.php and edit.blade.php.
What I need is to know is how to retrive data from database to populate data to those inputs when I click on edit.Then when I click on Add button in index.blade.php ,I'll be redirected to create.blade.php and then inputs must be empty.
I tried to add some code functions to every input value
{{old('title',$page->title}} then {{ isset($page) ? page->title: ''}}
but its not working
I'm using one form to perform create and update actions
This is the edit.blade.php
#extends('layouts.master')
#section('content')
<div class="card">
<div class="card-header card-header-success">
<h4 class="card-title ">Pages Data Table</h4>
<p class="card-category"> Here you can update Page data</p>
</div>
<div class="card-body">
{!! Form::open(['action' => 'PagesController#store', 'method' => 'POST' ]) !!}
#csrf
#method('PUT')
#include('pages.includes.form')
{!! Form::close() !!}
</div>
</div>
#endsection
and this is the child form form.blade.php
<div class="form-group">
{{Form::label('title', 'Title')}}
{{ Form::text('title', '',['class' => 'form-control', 'placeholder' => 'Title']) }}
</div>
<div class="form-group">
{{Form::label('content', 'Content')}}
<br>
{{ Form::textarea('content', '',['class' =>'form-control', 'placeholder'=> 'Content']) }}
</div>
<div class="form-group">
<div class="form-check form-check-radio">
<label class="form-check-label">
{{Form::input('radio','status', '0',['class' => 'form-check-input','checked'=>'checked'])}} Status Off
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
<div class="form-check form-check-radio">
<label class="form-check-label">
{{Form::input('radio','status', '1',['class' => 'form-check-input'])}} Status On
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
</div>
<input type="submit" name="submit" class="btn btn-success" value="Save">
When you are using the same form for create and update, you can use the optional method.
<input type="text" class="form-control{{ $errors->has('date') ? ' is-invalid' : '' }}" name="date" id="date" value="{{ old('date', optional($expense)->date) }}">
In the create function send the variable as null like $expense = null;
And in edit function the variable has its own value from database. So when the variable has its value the input field will be filled by value from database otherwise it will be empty.
i am new in laravel . need help how to display current date in laravel 5.1 ..?
this is my form page:
<div class="col-sm-6 padding-5px">
<div class="form-group">
<div class="col-xs-12">
{!! Form::label('dato','date here', array('class' => 'control-label')) !!}
{!! Form::text('dato',Carbon\Carbon::today()->format('d.m.Y'),array('class'=>'form-control datepicker','data-date-format'=>'dd.mm.yyyy','readonly'=>'true')) !!}
</div>
</div>
</div>
try bellow code,
remove class datepicker from, input tag and initialize datepacker like bellow. this will may help you.
<div class="col-sm-6 padding-5px">
<div class="form-group">
<div class="col-xs-12">
<label class="control-label">Date Hear</label>
<input type="text" name="dato" id="dato" class="form-control" value="<?php echo date('d-m-Y'); ?>"/>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$("#dato").datepicker({
format: "dd-M-yyyy"
});
});
</script>
im trying to build a user login and registration form and this is my route :
Route::get('/register', function()
{
return View::make('register');
});
Route::get('/register', function()
{
$user = new User;
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->save();
$username = Input::get('username');
return View::make('registered')->with('username',$username);
});
and this is my html :
<div class="container">
{{ Form::open(array('url' => 'register', 'class' => 'form-horizontal')) }}
<fieldset>
<!-- Form Name -->
<legend>Form Name</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="username"></label>
<div class="col-md-4">
<input id="username" name="username" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="password"></label>
<div class="col-md-4">
<input id="password" name="password" type="password" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Appended checkbox -->
<div class="form-group">
<label class="col-md-4 control-label" for="appendedcheckbox"> </label>
<div class="col-md-4">
<div class="input-group">
<input id="appendedcheckbox" name="appendedcheckbox" class="form-control" type="text" placeholder="">
<span class="input-group-addon">
<input type="checkbox">
</span>
</div>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"> </label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-inverse"> </button>
</div>
</div>
</fieldset>
</div>
few problems :
1.
my form does not loads and i see just
the last button for submitting the form and : ' you have registered in $username ' which i design to loads AFTER user submitted
2.my localhost:8000 loaded laravel first page one time but when i began to work on the project i just receiving blank white page and currently accessing my file like this : http://localhost/vendor/bin/crm/public/register
3.
is hashing in laravel secure enough? or should i do something else ?
4.
my way of doing this is alright or there is a better way for login and reg using laravel ?
You have two routes responding to get requests on /register. Change the second one to Route::post(...) and I would also change both to just register. There isn't a need to prepend a slash onto your routes.
Hashing in Laravel is secure and shouldn't be something you have to worry about.
There really isn't a "right" way of doing things, it really depends on how the rest of your app works, how complicated it is, and how easy it should be to maintain. If it were me though, I would have a LoginController with a method for showing the view and a method for creating the user and have those methods respond to the request rather than putting everything right in your routes.php file.
You are also missing a {{ Form::close() }} at the end of your view as well.
I'm trying to build a search form in Laravel such that when a user presses the search button, all the contacts matching the search criteria are displayed on the same page.
Below is my form:
{{ Form::open(array('url' => '/directory', 'class' => 'form-horizontal')) }}
<div class="form-group">
<label for="lastname" class="col-sm-2 control-label">Last Name</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="lastname" placeholder="Enter Last Name">
</div>
</div>
<div class="form-group ">
<label for="phone" class="col-sm-2 control-label">Phone</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="phone" placeholder="Enter Phone number">
</div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-sm-2 control-label">Email</label>
<div class="col-sm-6">
<input type="email" class="form-control" id="inputEmail1" placeholder="Enter Email - leave blank if you are not sure">
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn-u btn-u-green">Search</button>
</div>
</div>
<div class="well">
#foreach($users as $user)
<li>{{$user->firstname}} {{$user->lastname}}</li>
#endforeach
</div>
{{ Form::close() }}
The screenshot below gives a pictorial view of my form:
My route is defined as follow:
Route::get('/directory', 'UsersController#filter');
Now, whenever I press the search button, I am getting a MethodNotFound exception.
What I really want to do is to show the search results below the search button.
Edit ..
Everything is working fine now except for one thing.
I'm displaying the data in my view (getting the list of all the users on my page which match the search criteria) but the for loop is not getting executed.
<li>Count of users = {{ $users->count() }}</li>
<li>{{$users->first()->lastname}}</li>
#foreach ($users as $user)
<p>This is user {{ $user->id }}</p>
#endforeach
So: while I can see the count and the lastname of the first user in the resultant array of records, the foreach loop is not getting executed.
What am I doing wrong?
Laravel routes are bound to the form METHOD, so you need to create also a POST route:
Route::post('/directory', 'UsersController#filter');
You also need to add names to your form fields:
name="lastname"
for
<input type="text" name="lastname" class="form-control" id="lastname" placeholder="Enter Last Name">
And for all the others.
A controller method to handle that query could look like this:
<?php
class UsersController extends Controller {
public function filter()
{
$users = User::query();
if (Input::has('lastname'))
{
$users->where('lastname', Input::get('lastname'))
}
if (Input::has('phone'))
{
$users->where('phone', Input::get('phone'))
}
return View::make('your.view')
->with('userCount', $users->count());
->with('users', $users->get());
}
}
And in your view you can just:
<li>Count of users = {{$userCount}}</li>
#foreach ($users as $user)
<li>
{{ $user->id }} - {{$user->lastname}}
</li>
#endforeach
You have to tell Laravel that you want to use get method for submitting a form to the server. otherwise, Laravel will use post method by default.
Try the following:
{{ Form::open(array('url' => '/directory', 'method' => 'get', 'class' => 'form-horizontal')) }}
^^^