In my route file
Route::get('griev_reg_form', 'GrievanceRegisterController#show');
Route::post('griev_reg_form', 'GrievanceRegisterController#postdata');
and in controller
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\GrievanceRegister;
use App\Department;
use Input;
use Validator;
use Redirect;
use Session;
class GrievanceRegisterController extends Controller
{
public function show()
{
$departments = Department::orderBy('edesc','ASC')->get();
return view('griev_reg_form', array('departments' => $departments));
}
public function postdata()
{
$data = Input::all();
// print_r($data);
echo $name = Input::get('name');
$rules = array(
'name' => 'required',
'email_address' => 'required|email',
'g-recaptcha-response' => 'required|captcha',
);
$validator = Validator::make($data, $rules);
if ($validator->fails()){
echo "1";
return Redirect::to('/griev_reg_form')->withInput()->withErrors($validator);
}
else{
// Do your stuff.
}
}
}
?>
and in the view file
{!! Form::open(array('url'=>'griev_reg_form','method'=>'POST', 'id'=>'myform')) !!}
<div class="box-body">
<div class="form-group">
<label class="col-sm-3 control-label">Grievance Case:
</label>
<label>
<input type="radio" name="gretype" class="minimal" checked>
</label>
<label>Normal Case
</label>
<label>
<input type="radio" name="gretype" class="minimal">
</label>
<label>
NRI
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Grievance/Demand/Suggestion/Others:
</label>
<label>
<input type="radio" name="sugg_demand" class="minimal" checked value="G">
</label>
<label>Grievance
</label>
<label>
<input type="radio" name="sugg_demand" class="minimal" value="S">
</label>
<label>
Suggestion
</label>
<label>
<input type="radio" name="sugg_demand" class="minimal"
value="D">
</label>
<label>
Demand
</label>
<label>
<input type="radio" name="sugg_demand"
class="minimal" value="O">
</label>
<label>
Others
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Department/Office:
</label>
<select class="form-control select2" name="dept_name" style="width: 28%;">
<option value="">Select Department</option>
<?php
foreach($departments as $result)
{
?>
<option value="<?php echo $result->deptcode; ?>"><?php echo $result->edesc; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Mobile No:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="mobileno">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Alternative Mobile No:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="amobileno">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Received Date:</label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" name="recvd_date" id="datepicker" readonly="">
</div>
<!-- /.input group -->
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Name:</label>
<input type="text" class="form-control" name="cname">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Individual or Group Complainant(s):
</label>
<label>
<input type="radio" name="indiv_grp" value="I" class="minimal" checked>
</label>
<label>Individual
</label>
<label>
<input type="radio" name="indiv_grp" value="G" class="minimal">
</label>
<label>Group
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">AADHAR Card Number:</label>
<input type="text" class="form-control" name="idproofdetail">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Address:</label>
<input type="text" class="form-control" name="address1">
</div>
<div class="form-group">
<input type="text" class="form-control box-right" name="address2">
</div>
<div class="form-group">
<input type="text" class="form-control box-right" name="address3">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Pin code:</label>
<input type="text" class="form-control" name="pincode">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Email:</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
<input type="email" class="form-control" placeholder="Email" name="email_address">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">District:
</label>
<select class="form-control select2" name="district_problem" style="width: 28%;">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">विधानसभा निर्वाचन क्षेत्र /Assembly Constituency:
</label>
<select class="form-control select2" name="ac_problem" style="width: 28%;">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Area:
</label>
<label>
<input type="radio" value="urban" name="problem_area" class="minimal" checked>
</label>
<label>Urban
</label>
<label>
<input type="radio" value="rural" name="problem_area" class="minimal">
</label>
<label>
Rural
</label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Town/Block:
</label>
<select class="form-control select2" name="city_problem" style="width: 28%;">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Please Enter Specific Details about Your Grievance </label>
<textarea class="form-control" rows="3" name="Description" placeholder="Enter ..."></textarea>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">What do you want?</label>
<textarea class="form-control" rows="3" name="remedies" placeholder="Enter ..."></textarea>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Upload(Relevant Document):</label>
<input type="file" class="form-control">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Captcha</label>
<label class="col-sm-3 control-label">
{!! app('captcha')->display(); !!}
</label>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Submit
</button>
</div>
</div>
</form>
when i click on submit button without filling any data, its doesn't go
on validation part
Please provide help how can i check the post value of input fileds as well as
captcha and also validate accordingly
I have checked your view..I didnt find any input field named as "name", you have "cname" so maybe you validation rule should be:
$rules = array(
'cname' => 'required',
'email_address' => 'required|email',
'g-recaptcha-response' => 'required|captcha'
);
In case you are using >=5.3 version then you should use:
public function postdata(Request $request)
{
//validation
$validationArray = [
'cname' => 'required',
'email_address' => 'required|email',
'g-recaptcha-response' => 'required|captcha'
];
$validator = Validator::make($request->all(),$validationArray);
if ($validator->fails()) {
$response = ['errors' => $validator->messages()->all()];
return Response::json($response,200);
}
//here if validation is successful
}
Ofcourse add at top of controller: use Illuminate\Http\Request;
Related
I'm trying to insert the input data from a modal but I don't know how to achieve this. I'm not really familiar with AJAX(I apologize for that). I did some readings and research but I'm getting confused. Here is my modal content reserve_form.php
<form action="" id="book-form">
<div class="row flex-lg-row-reverse align-items-center pt-1">
<h3>Reservation Details</h3>
<div class="col-10 col-sm-8 col-lg-6">
<input type="hidden" name="package_id" value="<?php ?>">
<div class="form-group">
<label for="date_start" class="control-label">Reserve Date:</label>
<input type="date" name="date_start" id="date_start" class="form-control form-conrtrol-sm rounded-0" min="<?php echo date("Y-m-d") ?>" value="<?php echo date("Y-m-d") ?>" required>
</div>
<div id="msg" class="text-danger"></div>
<div id="check-availability-loader" class="d-none">
<center>
<div class="d-flex align-items-center col-md-6">
<strong>Checking Availability...</strong>
<div class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
</div>
</center>
</div>
<div class="form-group">
<label for="quantity" class="control-label">Number of Person <span><i>(Max. of 15 person)</i></span></label>
<input type="number" class="form-control form" required name="person" value="">
</div>
<div class="form-group">
<label for="amount" class="control-label">Additional Inclusions</label>
<div>
<input type="checkbox" id="inclusion" name="inclusion" value="">
<label for="inclusion"> Unlimited Samgyupsal & Al Fresco dining experience</label>
</div>
</div>
<div class="form-group">
<label for="amount" class="control-label">Total Amount</label>
<input type="number" name="cost" id="amount" class="form-control form-conrtrol-sm rounded-0 text-right" value="<?php echo isset($cost) ? number_format($cost, 2) : 0.00 ?>" required readonly>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="name" class="control-label">First Name</label>
<input type="text" class="form-control mb-3" name="firstname" placeholder="Enter First Name" value="">
</div>
<div class="form-group">
<label for="name" class="control-label">Last Name</label>
<input type="text" class="form-control mb-3" name="lastname" placeholder="Enter Last Name" value="">
</div>
<div class="form-group">
<label for="name" class="control-label">Contact</label>
<input type="text" class="form-control mb-3" name="contact" placeholder="09xx-xxx-xxxx" value="">
</div>
<div class="form-group">
<label for="name" class="control-label">Email</label>
<input type="text" class="form-control mb-3" name="email" placeholder="example#email.com" value="">
</div>
</div>
</div>
<div class="modal-footer py-2">
<button class="btn btn-warning" type="submit" name="details">Save</button>
<button class="btn btn-secondary "><span class="close-sm">Close</span></button>
</div>
</form>
Here's my modal in view.php
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header py-1">
<h3><?php echo $packages->title; ?></h3>
</div>
<div class="modal-body py-2">
<?php $this->load->view('forms/reserve_form'); ?>
</div>
</div>
Here' my Controller(page.php)
public function reservation_details()
{
$details = array();
$details2 = array();
if ($this->input->post('details')) {
$this->form_validation->set_rules('firstname', 'First Name', 'required');
$this->form_validation->set_rules('lastname', 'Last Name', 'required');
$this->form_validation->set_rules('contact', 'Contact', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('date_start', 'Reserve Date', 'required');
$this->form_validation->set_rules('person', 'Number of Person', 'required|max_length[15]');
if ($this->form_validation->run() == true) {
$details = array(
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'contact' => $this->input->post('contact'),
'email' => $this->input->post('email'),
);
$this->UI_model->reserve_details($details);
$details2 = array(
'date_start' => $this->input->post('date_start'),
'person' => $this->input->post('person'),
'inclusion' => $this->input->post('inclusion'),
);
$this->UI_model->reserve_add($details2);
}
}
}
Here's the Model
public function reserve_details(){
if (!empty($data)) {
$this->db->insert('clients', $data);
return $this->db->insert_id();
}
return false;
}
public function reserve_add(){
if (!empty($data)) {
$this->db->insert('book_list', $data);
return $this->db->insert_id();
}
return false;
}
Also, I'm trying to insert the data for multiple tables. Any help will be much appreciated. Thanks! Is is also fine to place the submit button at modal footer? or it should be at reserve.php?
You're passing data array through these functions.
$this->UI_model->reserve_details($details);
$this->UI_model->reserve_add($details2);
But in the model, you're not catching those.
public function reserve_details(){
public function reserve_add(){
So it should be
public function reserve_details($data){
public function reserve_add($data){
Since you're checking if (!empty($data)) { its always retuns false, unless Undefixed Varibale error.
how can I "tell" laravel that if the email field with validation rule 'email' and URL field (for example field where I expect the user to put his Facebook account link but that field IS NOT required) with validation rule 'URL' is not required and it is fine if it is empty. I have put nullable() on all database table columns but my validation rule still applies like it is required. Here are the parts of the code.
This is from migration:
$table->string('site_facebook')->nullable();
$table->string('site_instagram')->nullable();
$table->string('site_twitter')->nullable();
$table->string('site_linkedin')->nullable();
$table->string('site_behance')->nullable();
$table->string('site_dribbble')->nullable();
$table->string('site_email')->nullable();
This part is from validation:
'site_facebook' => 'url',
'site_facebook' => 'url',
'site_instagram' => 'url',
'site_twitter' => 'url',
'site_linkedin' => 'url',
'site_behance' => 'url',
'site_dribbble' => 'url',
'site_email' => 'email',
So, to wrap up my question. I want my URL and email fields to be optional not required :)
EDIT
Since there are some answers and no one work for me I just want to mention (if it does do anything with it), all of my validation rules are in a separate request...
class ManageSiteSettingsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* #return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* #return array
*/
public function rules()
{
return [
'site_name' => 'required|max:50',
'site_facebook' => 'nullable|url',
'site_facebook' => 'url',
'site_instagram' => 'url',
'site_twitter' => 'url',
'site_linkedin' => 'url',
'site_behance' => 'url',
'site_dribbble' => 'url',
'site_email' => 'email',
'site_creator_link' => 'url',
];
}
}
This is the form:
#extends('layouts.admin')
#section('content')
<h2>Site settings</h2>
#include('includes._errors')
#include('includes._sessions')
<form action="{{ route('settings.update') }}" method="post">
#csrf
<div class="form-group">
<label for="site_name">Site name</label>
<input type="text" name="site_name" class="form-control" required placeholder="This field is required!" value="{{ $settings->site_name }}">
</div>
<div class="form-group">
<label for="site_description">Site description</label>
<textarea name="site_description" class="form-control mytinytext" id="site_description" cols="30" rows="10">{!! $settings->site_description !!}</textarea>
</div>
<div class="form-group">
<label for="site_facebook">Site facebook page</label>
<input type="text" name="site_facebook" class="form-control" placeholder="https://www.facebook.com/" value="{{ $settings->site_facebook }}">
</div>
<div class="form-group">
<label for="site_instagram">Site instagram page</label>
<input type="text" name="site_instagram" class="form-control" placeholder="https://www.instagram.com/" value="{{ $settings->instagram }}">
</div>
<div class="form-group">
<label for="site_twitter">Site twitter page</label>
<input type="text" name="site_twitter" class="form-control" placeholder="https://twitter.com/" value="{{ $settings->site_twitter }}">
</div>
<div class="form-group">
<label for="site_linkedin">Site linkedin page</label>
<input type="text" name="site_linkedin" class="form-control" placeholder="https://www.linkedin.com/" value="{{ $settings->site_linkedin }}">
</div>
<div class="form-group">
<label for="site_behance">Site behance page</label>
<input type="text" name="site_behance" class="form-control" placeholder="https://www.behance.net/" value="{{ $settings->site_behance }}">
</div>
<div class="form-group">
<label for="site_dribbble">Site dribbble page</label>
<input type="text" name="site_dribbble" class="form-control" placeholder="https://dribbble.com/" value="{{ $settings->site_dribbble }}">
</div>
<div class="form-group">
<label for="site_email">Site email</label>
<input type="text" name="site_email" class="form-control" placeholder="...#outlook... / ...#hotmail... / ...#gmail..." value="{{ $settings->site_email }}">
</div>
<hr class="divider">
<div class="form-group">
<label for="site_field_one">First footer field title</label>
<input type="text" name="site_field_one" class="form-control" placeholder="PHONE" value="{{ $settings->site_field_one }}">
</div>
<div class="form-group">
<label for="site_field_one_value">First footer field value</label>
<textarea name="site_field_one_value" id="site_field_one_value" class="mytinytext form-control" placeholder="+80 (0)5 22 55 66 77">{{ $settings->site_field_one_value }}</textarea>
</div>
<hr class="divider">
<div class="form-group">
<label for="site_field_two">Second footer field title</label>
<input type="text" name="site_field_two" class="form-control" placeholder="ADDRESS" value="{{ $settings->site_field_two }}">
</div>
<div class="form-group">
<label for="site_field_two_value">Second footer field value</label>
<textarea name="site_field_two_value" id="site_field_two_value" class="mytinytext form-control" placeholder="33 rue Burdeau 69089, Paris France">{{ $settings->site_field_two_value }}</textarea>
</div>
<hr class="divider">
<div class="form-group">
<label for="site_field_three">Third footer field title</label>
<input type="text" name="site_field_three" class="form-control" placeholder="ENQUIRUES" value="{{ $settings->site_field_three }}">
</div>
<div class="form-group">
<label for="site_field_three_value">Third footer field value</label>
<textarea name="site_field_three_value" id="site_field_three_value" class="mytinytext form-control" placeholder="email#gmail.com">{{ $settings->site_field_three_value }}</textarea>
</div>
<hr class="divider">
<div class="form-group">
<label for="site_field_four">Fourth footer field title</label>
<input type="text" name="site_field_four" class="form-control" placeholder="WORK HOURS" value="{{ $settings->site_field_four }}">
</div>
<div class="form-group">
<label for="site_field_four_value">Fourth footer field value</label>
<textarea name="site_field_four_value" id="site_field_four_value" class="mytinytext form-control" placeholder="Weekdays: 09:00 - 18:00 Weekends: 11:00 - 17:00">{{ $settings->site_field_four_value }}</textarea>
</div>
<hr class="divider">
<div class="form-group">
<label for="site_copyright">Site copyright</label>
<input type="text" name="site_copyright" class="form-control" placeholder="Created with love by _______ (fill 'Site creator name' field)" value="{{ $settings->site_copyright }}">
</div>
<hr class="divider">
<div class="form-group">
<label for="site_creator_name">Site creator name</label>
<input type="text" name="site_creator_name" class="form-control" placeholder="John Doe" value="{{ $settings->site_creator_name }}">
</div>
<div class="form-group">
<label for="site_creator_link">Site creator page</label>
<input type="text" name="site_creator_link" class="form-control" placeholder="https://site-creator-page.com" value="{{ $settings->site_creator_link }}">
</div>
<div class="form-group">
<button type="submit" name="btn_update_site_settings" class="btn btn-block btn-success">Update site settings</button>
</div>
</form>
#include('includes._errors')
#endsection
You can use nullable rule
Like the example below:
'site_facebook' => 'url|nullable',
I have a form and using select2 for filter. I want to show new column by using this select2.
I don't know its possible or not but i want to do this . using jquery or something, can someone reference to me about this? its my form for my input
<form class="form-prevent-multiple-submits" data-toggle="validator" action="{{route('update_sarpras_aduan'),'test'}} " method="post">
#csrf
{{method_field('patch')}}
<div class="form-group">
<label class="control-label" for="title">Nama Unit:</label>
<input type="text" name="nama_unit" id="nama_unit" class="form-control" data-error="Please enter title." required disabled/>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="title">Tanggal Aduan:</label>
<textarea name="created_at" class="form-control" id="tgl_aduan" data-error="Please enter description." readonly ></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="title">Nama Pengadu:</label>
<input type="text" name="nama_pengadu" class="form-control" id="nama_pengadu" data-error="Please enter title." readonly />
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label> Isi Aduan </label>
<textarea name="aduan" id="aduan" class="form-control" rows="3" placeholder="Isi Aduan atau Keluhan ..." readonly ></textarea>
</div>
<div class="form-group">
<label class="control-label" for="title">Nama Teknisi:</label>
<input type="text" name="nama_teknisi" class="form-control" id="nama_teknisi" data-error="Please enter title." readonly />
<div class="help-block with-errors"></div>
</div>
----------------here this select2---------------------------
<div class="form-group">
<label>Pilih Inventaris</label>
<select class="form-control select2bs4" name="alat_id" id="alat_id" style="width: 100%;" aria-hidden="true">
#foreach($inven as $id => $item )
<option value="{{ $id }}">{{ $item }} </option>
#endforeach
</select>
</div>
--------------------------------------------------
<div class="form-group">
<label>Status Saat Ini (Jangan Lupa Diganti)</label>
<select name="status" id="status" class="form-control">
<option value="Tindakan Lanjutan">Tindakan Lanjutan</option>
<option value="Selesai">Selesai</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label> Tindakan Pelaksana </label>
<textarea name="tindakan" id="tindakan" class="form-control" rows="3" placeholder="Isi Tindakan Yang dilakukan" required ></textarea>
</div>
<div class="form-group">
<label>Kondisi Alat </label>
<select name="status_alat" id="status_alat" class="form-control">
<option value="Baik">Baik</option>
<option value="Rusak Ringan">Rusak Ringan</option>
<option value="Rusak Berat">Rusak Berat</option>
</select>
<div class="help-block with-errors"></div>
</div>
<input type="hidden" name="id" id="id" value="">
<input type="hidden" name="user_id" id="user_id" value="">
<input type="hidden" name="ipsrs_id" id="ipsrs_id" value="">
<input type="hidden" name="teknisi_id" id="teknisi_id" value="">
<input type="hidden" name="ended_at" id="ended_at" value="">
<div class="form-group">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" id="button" class="btn btn-success crud-submit-edit button-prevent-multiple-submits">
<i class="spinner fa fa-spinner fa-spin" ></i>
Submit</button>
</div>
</form>
after using this select2 , will showing a new form . can someone references to me about this ?
//select input
<div class="form-group">
<label>Pilih Inventaris</label>
<select class="form-control select2bs4" name="alat_id" id="alat_id" style="width: 100%;" aria-hidden="true" onchange="Show()">
#foreach($inven as $id => $item )
<option value="{{ $id }}">{{ $item }} </option>
#endforeach
</select>
</div>
//new form
<div id="divid" style="display:none">
<form method="" action="">
#csrf
</form
<div>
//javascript code
<script>
function Show()
{
var fieldValue = $('#alat_id').val();
if(fieldValue == "")
{
document.getElementById("divid").style.display = 'none';
}
else{
document.getElementById("divid").style.display = 'inline'
}
}
</script>
I'm getting an error as "Name and email address are required if not a client" while running the below mentioned code.
Find below the Controller Code:
class UserController extends Controller
{
public function insertform(){
return view('test');
}
public function create(){
$user=Whmcs::AddClient([
'firstname' => Input::get('firstname'),
'lastname' => Input::get('lastname'),
'email' => Input::get('email'),
'address1' => Input::get('address1'),
'city' => Input::get('city'),
'state' => Input::get('state'),
'postcode' => Input::get('postcode'),
'country' => Input::get('country'),
'phonenumber' => Input::get('phonenumber'),
'password2' => Input::get('password2'),
]);
return $user;
}
}
Find below the route code:
Route::get('insert', 'UserController#insertform');
Route::post('create', 'UserController#create')->name('user.create');
The blade file is given below
<div id="content" class="app-content" role="main">
<div class="app-content-body ">
<div class="bg-light lter b-b wrapper-md">
<h1 class="m-n font-thin h3">Sign up</h1>
</div>
<div class="wrapper-md" ng-controller="FormDemoCtrl">
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading font-bold">create an account</div>
<div class="panel-body">
<form class="bs-example form-horizontal" action="
{{route('user.create')}}" method="post">
<input type = "hidden" name = "_token" value = "<?php echo
csrf_token(); ?>">
<div class="form-group">
<label class="col-lg-2 control-label">firstname</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="firstname"
placeholder="Name">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">lastname</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="lastname"
placeholder="Name">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">Email</label>
<div class="col-lg-6">
<input type="email" class="form-control" name="email"
placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">address1</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="address1"
placeholder="Subject">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">city</label>
<div class="col-lg-6">
<select class="form-control" name="city">
<option value="-- Select --">-- Select --</option>
<option value="Coimbatore">Coimbatore</option>
<option value="Chennai">Chennai</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">state</label>
<div class="col-lg-6">
<select class="form-control" name="state">
<option value="-- Select --">-- Select --</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andhra">Andhra</option>
<option value="Karnataka">Karnataka</option></select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">country</label>
<div class="col-lg-6">
<select class="form-control" name="country">
<option value="-- Select --">-- Select --</option>
<option value="India">India</option>
<option value="China">China</option>
<option value="Australia">Australia</option></select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">postcode</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="postcode"
placeholder="postcode">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">phonenumber</label>
<div class="col-lg-6">
<input type="text" class="form-control" name="phonenumber"
placeholder="phonenumber">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">password</label>
<div class="col-lg-6">
<input type="password" class="form-control" name="password2"
placeholder="password">
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-sm btn-
success">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
When I run the above code I'm getting an error as below:
{"result":"error","message":"Name and email address are required if not a client"}
suggest me a solution to solve this and post the data in laravel.
I have gone through similar posts on SO but nothing has worked for me and also not found relative answer. Even it is not updating data.
{!! Form::model($editClient, [ 'method' => 'PATCH','route' => ['clients.update', $editClient->id],'class' => 'form-horizontal', 'id'=>'edit-client' ]) !!}
#include('clients._form')
I am using form as partial
Route:
Route::resource('clients', 'ClientController');
Controller Method:
public function edit($id)
{
$editClient = User::findOrFail($id);
return view('clients.edit', compact('editClient'));
}
HTML:
<div class="form-group">
<label class="control-label col-sm-2" for="username">Username:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="email" name="user_name" placeholder="Enter Username">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="pwd" name="password" placeholder="Enter password">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="contact">Contact Number: </label>
<div class="col-sm-10">
<input type="number" class="form-control" id="contact" name="contact" placeholder="Enter Contact Number">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
From the Laravel Collective docs for Form model binding (https://laravelcollective.com/docs/5.4/html#form-model-binding):
{{ Form::model($user, ['route' => ['user.update', $user->id]]) }}
You have $editClient whereas I think your model is probably $client