chess/resources/views/content/ref/Task/action.blade.php
Ramadhon Ikhsan Prasetya 603e31b0f4 init
2024-08-29 10:56:32 +07:00

63 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);
$('#task_name').val(data.task_name);
$('#task_type_id').val(data.task_type_id).trigger('change.select2');
var active = data.is_active?'true':'false';
$('#is_active').val(active);
$('#formData').data('bootstrapValidator').validate();
})
}
//VALIDASI
$(document).ready(function () {
validation = FormValidation.formValidation(
KTUtil.getById('formData'),
{
fields: {
task_name: {
validators: {
notEmpty: {
message: 'Wajib diisi!'
}
}
},
task_type_id: {
validators: {
notEmpty: {
message: 'Wajib diisi!'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap()
}
}
);
});
</script>