⚠ 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

Grocery crud on sql view



fredconv

fredconv
  • profile picture
  • Member

Posted 17 September 2012 - 11:37 AM

Hi
Not really a question but more something to share:
If i try to use grocery crud on a sql view, i got an error.. after jsut a quick search, i found that since the primary key is needed (for the edit and delete actions) , it s normal that the render crash :) because there was no check on this.

currently i m modified the grocery_crud.php file from
(line 1385)

foreach($data->list as $num_row => $row)
{
$data->list[$num_row]->edit_url = $data->edit_url.'/'.$row->{$data->primary_key};
$data->list[$num_row]->delete_url = $data->delete_url.'/'.$row->{$data->primary_key};

}


to


foreach($data->list as $num_row => $row)
{
if ($data->primary_key){
$data->list[$num_row]->edit_url = $data->edit_url.'/'.$row->{$data->primary_key};
$data->list[$num_row]->delete_url = $data->delete_url.'/'.$row->{$data->primary_key};
}
}


and , of course I ve unset operations from the controller since you can t modify view field :)
if anyone has a better solution or something that could be more useful, feel free to post it :)

thanks

fred