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

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