I have a problem in using a datepicker for my data. I need to input only the month and year for my database. This is my type for the data
So far i have this view:
<div class="form-group">
<label for="Periode" class="col-md-2">
Periode <text style="color:red"><b>*</b></text>
</label>
<div class="col-md-4">
<script type="text/javascript">
$(function() {
$("#periode").datepicker({
dateFormat: 'YYYY-MM',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
onClose: function(date, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).val($.datepicker.formatDate('MM yy', new Date(year, month, 1)));
}
});
$("#periode").focus(function () {
$(".ui-datepicker-calendar").hide();
$("#ui-datepicker-div").position({
my: "center top",
at: "center bottom",
of: $(this)
});
});
});
</script>
<input class="form-control" name="periode" id="periode" data-format="YYYY-MM" class="Periode" required />
The datepicker is working (it shows only month and year in the display)
But Once i clicked the submit button, the data is not successfully inputed into the database, i checked the data from xampp and it clearly shows 0000-00-00 in the table
Is there any better solution for the problem? already tried to look on another questions but i can't find any clear solution :/
EDIT: in case if you are wondering, this is the controller
public function submit(){
$data = array(
'kode_karyawan'=>$this->input->post('kode_karyawan'),
'nama_karyawan'=>$this->input->post('nama_karyawan'),
'periode'=>$this->input->post('periode')
);
$this->absengaji_m->insert($data);
redirect('absengaji');
}
}
and this is the model:
public function insert($data){
print_r($data);
$this->db->insert('uangmakan',$data);
}