64 lines
1.7 KiB
PHP
64 lines
1.7 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);
|
|
$('#unit_name').val(data.unit_name);
|
|
$('#unit_code').val(data.unit_code);
|
|
$('#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: {
|
|
unit_name: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
unit_code: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
});
|
|
</script>
|
|
|