⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

$crud->field trouble error



j-gun
  • profile picture
  • Member

Posted 17 September 2012 - 06:46 AM

Dear all,

I'm new in grocery CRUD and I have trouble inserting data into database with these following code:

[quote]function school_years_display() {
$this->load->library('grocery_CRUD');
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('school_years');
$crud->set_subject('Tahun Ajaran');
$crud->columns('school_years','odd_semester_start','odd_semester_end','even_semester_start','even_semester_end','active_semester');
$crud->required_fields('school_years','odd_semester_start','odd_semester_end','even_semester_start','even_semester_end');
$crud->fields('school_years','odd_semester_start','odd_semester_end','even_semester_start','even_semester_end');

$output = $crud->render();

$this->_crud_output($output);

}[/quote]

but after i comment these line, now i can inserting data into database normally
[i] $crud->fields('school_years','odd_semester_start','odd_semester_end','even_semester_start','even_semester_end');[/i]

midnigther
  • profile picture
  • Member

Posted 17 September 2012 - 08:40 AM

Well, it seems that you forgot to set the remaining values from table school_years.
You show this fields:

$crud->columns('school_years','odd_semester_start','odd_semester_end','even_semester_start','even_semester_end','active_semester');

Although maybe is necessary to set a value for all columns although not used.

j-gun
  • profile picture
  • Member

Posted 18 September 2012 - 00:26 AM

@midnighter

I try to use $crud->field method to another controller and it works as usual. But not with school_years controller. I already set the default value by null in database, it should be okay if i not included those field in CRUD.

Thanks anyway for your kindly reply :)