With my code below, when i submit the form, the name and email field in the database is saved empty. This tells i am not able to retrieve the inputs even though i am using the right name elements for the inputs.
What am i doing wrong here? HTML
<form action="/" class="fixed-form icons-tab-steps wizard-circle">
<!-- Step 1 -->
<h6><i class="step-icon ft-user"></i> Step 1</h6>
<fieldset>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="firstName2">Full Name :</label>
<input type="text" class="form-control square" id="name" value="{{$current_user->name}}" name="fullname">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="lastName2">Email Address :</label>
<input type="text" class="form-control square" value="{{$current_user->email}}" id="lastName2" name="email">
</div>
</div>
<!-- Step 4 -->
<h6><i class="step-icon ft-layout"></i>Step 4</h6>
<fieldset>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="firstName2">Your Company :</label>
<input type="text" class="form-control square" id="name" name="company">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="location2">Location :</label>
<input type="text" class="form-control square" id="name" name="location">
</div>
</div>
</fieldset>
</form>
JS
$(".icons-tab-steps").steps({
headerTag: "h6",
bodyTag: "fieldset",
transitionEffect: "fade",
titleTemplate: '<span class="step">#index#</span> #title#',
labels: {
finish: 'Submit'
},
onFinished: function (event, currentIndex) {
alert("Forms submitted.");
$.ajax({
method: 'GET', // Type of response and matches what we said in the route
url:'/user/update/2',
success: function(response){ // What to do if we succeed
console.log("paased");
},
error: function(jqXHR, textStatus, errorThrown) { // What to do if we fail
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
console.log("failed");
}
});
}
});
// Validate steps wizard
// Show form
var form = $(".steps-validation").show();
$(".steps-validation").steps({
headerTag: "h6",
bodyTag: "fieldset",
transitionEffect: "fade",
titleTemplate: '<span class="step">#index#</span> #title#',
labels: {
finish: 'Submit'
},
onStepChanging: function (event, currentIndex, newIndex)
{
// Allways allow previous action even if the current form is not valid!
if (currentIndex > newIndex)
{
return true;
}
// Forbid next action on "Warning" step if the user is to young
if (newIndex === 3 && Number($("#age-2").val()) < 18)
{
return false;
}
// Needed in some cases if the user went back (clean up)
if (currentIndex < newIndex)
{
// To remove error styles
form.find(".body:eq(" + newIndex + ") label.error").remove();
form.find(".body:eq(" + newIndex + ") .error").removeClass("error");
}
form.validate().settings.ignore = ":disabled,:hidden";
return form.valid();
},
onFinishing: function (event, currentIndex)
{
form.validate().settings.ignore = ":disabled";
return form.valid();
},
onFinished: function (event, currentIndex)
{
alert("Submitted!");
}
});
// Initialize validation
$(".steps-validation").validate({
ignore: 'input[type=hidden]', // ignore hidden fields
errorClass: 'danger',
successClass: 'success',
highlight: function(element, errorClass) {
$(element).removeClass(errorClass);
},
unhighlight: function(element, errorClass) {
$(element).removeClass(errorClass);
},
errorPlacement: function(error, element) {
error.insertAfter(element);
},
rules: {
email: {
email: true
}
}
});
Controller
$user = User::whereId($id)->firstorFail();
$user->name = $request->get('fullname');
$user->email = $request->get('email');
$user->save();