60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<script>
|
|
// INIT FORM
|
|
function clearForm() {
|
|
$('#get_id').val('');
|
|
$("#formData")[0].reset();
|
|
validation.resetForm();
|
|
$('#mForm_title').html(`Tambah Data`);
|
|
$('#mForm_subTitle').html(`Tambah Data `+title);
|
|
reInitForm();
|
|
}
|
|
|
|
function edit(id) {
|
|
clearForm();
|
|
$('#mForm').modal('show');
|
|
znLoadingModal('mForm');
|
|
$('#mForm_title').html(`Edit Data`);
|
|
$('#mForm_subTitle').html(`Edit Data `+title);
|
|
|
|
let formData = new FormData();
|
|
formData.append('id',id);
|
|
doPost(routeEdit, formData, function (msg, res) {
|
|
znLoadingModalEnd('mForm');
|
|
var data = res.data;
|
|
$('#get_id').val(data.id);
|
|
$('#model_id').val(data.model_id).trigger('change.select2');
|
|
$('#task_id').val(data.task_id).trigger('change.select2');
|
|
$('#formData').data('bootstrapValidator').validate();
|
|
})
|
|
}
|
|
|
|
//VALIDASI
|
|
$(document).ready(function () {
|
|
validation = FormValidation.formValidation(
|
|
KTUtil.getById('formData'),
|
|
{
|
|
fields: {
|
|
model_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
task_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
});
|
|
</script>
|
|
|