Question

When I try to fill the date box with the current time with a callback function like this:

<?php    
// in controller:
$this->grocery_crud->callback_add_field('date',array($this,'_date_fill_now'));


protected function _date_fill_now()
{
        return '<input name="date" type="text" value="'. current_time() . '" maxlength="19" class="datetime-input">';
}

The datepicker js files will not be loaded, so the datepicker doesn't pop up when I click on the date field. How can I load them the right way ?

Was it helpful?

Solution

A quick way to do it without changing the core of grocery CRUD is to add these lines of code at your controller:

$this->grocery_crud->set_js('assets/grocery_crud/js/jquery-1.7.1.min.js');
$this->grocery_crud->set_js('assets/grocery_crud/js/jquery_plugins/jquery.ui.datetime.js');
$this->grocery_crud->set_js('assets/grocery_crud/js/jquery_plugins/config/jquery.datetime.config.js');
$this->grocery_crud->set_js('assets/grocery_crud/js/jquery_plugins/jquery-ui-1.8.10.custom.min.js');
$this->grocery_crud->set_js('assets/grocery_crud/js/jquery_plugins/config/jquery.datepicker.config.js');

$this->grocery_crud->set_css('assets/grocery_crud/css/ui/simple/jquery-ui-1.8.10.custom.css');
$this->grocery_crud->set_css('assets/grocery_crud/css/jquery_plugins/jquery.ui.datetime.css');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top