[eluser]Unknown[/eluser]
I'm using an example of bootstrap-datetimepicker in my codeigniter project. I create a form with only the datetimepicker input.
view:
Code:
<?php // Change the css classes to suit your needs
$attributes = array('class' => '', 'id' => '');
echo form_open('/calendario/nadevent/', $attributes); ?>
<div class="form-group">
<label for="reservationtime">Fecha:</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" name="reservationtime" id="reservationtime" class="form-control" value="<?php echo set_value('reservationtime') ?>" />
</div>
</div>
<?php echo form_submit( 'submit', 'Submit','class="btn btn-default"'); ?>
<?php echo form_close(); ?>
JS:
Code:
$('#reservationtime').daterangepicker({timePicker: true, timePickerIncrement: 30, format: 'DD-MM-YYYY hh:mm:ss', timePicker12Hour: false, separator: '/'});
The datepicker works fine but when i submit the form, I want to format the data and split into an array:
Controller:
Code:
$this->form_validation->set_rules('reservationtime', 'reservationtime', '');
$array = explode('/',set_value('reservationtime'));
Then I try to insert the values:
Code:
$form_data = array(
'start' => $array[0],
'end' => $array[1]
);
But if I print the array, its empty:
Code:
Array ( [start] => [end] => )
Wha'ts wrong with the code?
Thanks for the help