This is my laravel blade page content of
<!-- Main Container -->
<main id="main-container">
<!-- Page Content -->
<div class="content" id="app">
<!-- Lock Forms -->
<!-- <h2 class="content-heading">Add Accessory</h2> -->
<!-- Register Forms -->
<div class="row">
<div class="col-md-12">
<!-- Bootstrap Register -->
<div class="block block-themed">
<div class="block-header bg-gd-dusk">
<h3 class="block-title">Add Accessory</h3>
</div>
<div class="block-content">
@include('errors.error')
<form enctype="multipart/form-data">
@csrf
<div class="form-group row">
<div class="col-12">
<label>Select Store</label>
<select class="form-control" name="store_id" v-model="form.store_id" required>
<option v-for="store in stores" :key="store.id" v-bind:value="store.id">@{{store.channel_id}}</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="col-12">
<label>Requested Date</label>
<input type="text" class="flatpickr form-control" v-model="form.request_date" name="request_date" required>
</div>
</div>
<div class="form-group row">
<div class="col-12">
<button type="button" @click="AddAccessory()" class="btn btn-primary">Add New Accessory</button>
</div>
</div>
</form>
</div>
</div>
<!-- END Bootstrap Register -->
</div>
</div>
</div>
<div class="modal fade" id="accessory" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Accessory Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form @submit="CreateAccessory()" enctype="multipart/form-data">
<div class="modal-body">
<div class="form-group row">
<div class="col-12">
<label>Choose Accessory Type</label>
<select class="form-control" name="type" required>
<option>Case</option>
<option>Projector</option>
<option>Glass</option>
<option>Charger</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="col-12">
<label>Description</label>
<textarea class="form-control" name="description" placeholder="Enter Description"> </textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</main>
<script>
var app = new Vue({
el: '#app',
mounted: function() {
},
data() {
return {
stores: {!! $stores !!},
users: {!! $users !!},
form: {
user_id: '',
request_date: '',
store_id: '',
type: '',
description: ''
},
}
},
methods: {
AddAccessory() {
$('#accessory').modal('show');
},
CreateAccessory() {
axios.post('/accessory/store',{
data: this.form,
})
.then(response => {
//$(location).attr('href', '/cashoutdetails')
})
.catch(function (error) {
alert('Error');
});
}
}
})
</script>
'''
In web.php, this is my route --
Route::post('accessory/store','AccessoryController@store');
My Issues are --
As you're not using any client side validation engine and relying on native HTML form constraints, we can continue on with the native constraints api. You can get all the elements of a form (in this case, by name) and callcheckValidity
on them. We can then loop each of those elements within the form to determine the validity state prior to showing our modal:
AddAccessory() {
const valid = [].slice.call(document.forms.add_accessory.elements).map((el) => {
return el.checkValidity()
}).filter((v) => v === false).length === 0
if (valid) {
$('#accessory').modal('show');
}
}
Make sure to give your form element a name so it can be found correctly:
<form name="add_accessory" type="multipart/form-data"
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
Bootstrap is not exclusively a CSS framework, but its most popular features are CSS-centric. These include a powerful grid, icons, buttons, map components, navigation bars, and more.
https://getbootstrap.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.