I tried write a callback functions, and it's work, but functions only effect on callback fields, the other "normal" field doesn't updated.
I don't understand the problem. Here's the code:
public function exhibitions()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('content');
$crud->where('catId = 11');
$crud->set_model('Grocery_crud_plus_model');
$crud->fields('title','text', 'date', 'view', 'fromDate', 'toDate');
$crud->columns('title','text', 'date', 'view', 'fromDate', 'toDate');
$crud->callback_field('fromDate',array($this,'from_call'));
$crud->callback_field('toDate',array($this,'to_call'));
$crud->callback_update(array($this,'update_call'));
$crud->callback_insert(array($this,'insert_call'));
$crud->required_fields('title', 'text', 'fromDate', 'toDate');
$crud->unset_edit_fields('date');
$output = $crud->render();
$this->output($output);
}
/**
* fromDate callback
*/
function from_call($value = '', $primary_key)
{
$query = $this->db->query("SELECT fromDate FROM exhtime WHERE contentId = '$primary_key'");
$value = $query->row('fromDate');
if($query->num_rows() == 0)
{
$value = '';
}
return '<div class="form-input-box" id="date_input_box"><input id="field-fromDate" name="fromDate" type="text" value="'.$value.'" maxlength="17" class="datetime-input" />
<a class="datetime-input-clear" tabindex="-1">ÃœrÃt</a>
(yyyy-mm-dd) hh:mm:ss</div>
<div class="clear"></div>';
}
/**
* toDate callback
*/
function to_call($value = '', $primary_key)
{
$query = $this->db->query("SELECT toDate FROM exhtime WHERE contentId = '$primary_key'");
$value = $query->row('toDate');
if($query->num_rows() == 0)
{
$value = '';
}
return '<input id="field-toDate" name="toDate" type="text" value="'.$value.'" maxlength="17" class="datetime-input" />
<a class="datetime-input-clear" tabindex="-1">ÃœrÃt</a>
(yyyy-mm-dd) hh:mm:ss</div>
<div class="clear"></div>';
}
/**
* to-fromDate update callback
*/
function update_call($post_array, $primary_key)
{
if(!empty($post_array['fromDate']) && !empty($post_array['toDate']))
{
$data = array(
'fromDate' => $post_array['fromDate'],
'toDate' => $post_array['toDate']
);
return $this->db->update('exhtime', $data, array('contentId' => $primary_key));
}
}