CodeIgniter Forums

Full Version: daterangepicker form not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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>&lt;input type="text"       name="reservationtime" id="reservationtime" class="form-control" value="&lt;?php echo       set_value('reservationtime') ?&gt;" /&gt;
       </div>

       </div>
   &lt;?php echo form_submit( 'submit', 'Submit','class="btn btn-default"'); ?&gt;
   &lt;?php echo form_close(); ?&gt;
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 Smile

El Forum

[eluser]InsiteFX[/eluser]
Code:
echo form_open('/calendario/nadevent/', $attributes); ?&gt;

// should be
echo form_open('calendario/nadevent/', $attributes); ?&gt;

El Forum

[eluser]CroNiX[/eluser]
I don't know anything about that datetimepicker, but it looks like you set the "format" to "DD-MM-YYYY hh:mmConfuseds" in the options, but you are exploding on "/"

What do you get if you:
die(set_value('reservationtime'));
??