⚠ 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

Functions created using one theme don't work in the other



Fabrizio
  • profile picture
  • Member

Posted 09 August 2013 - 10:18 AM

Hello to everyone,

 

here following i report an issue I have recently had, is there anywaone that could possibly help me to identify the source of the problem and fix it?

 

Lately I have tried to create a small application with Grocery Crud using the theme Flexgrid. I have added very few functions to customize it using GroceryCRUD ones.

As the filter system of the Flexigrid theme is not enough for my needs, recently I decided just to change the theme with the Datatable one because it has more filters... one for each column.

Everything seemed to be ok, but when i tested the funztionality of the funtions I added to my controller my functions didin't work anymore as with the Flexgrid theme.

 

Why this behaviour?

 

I attach to this post a copy of the main controller of the application.

The same fil without the line

 

$crud->set_theme('datatables');

works well

adding that line it doesn't work as expected.

 

I relly can't understand why. I have just changed the theme.


davidoster
  • profile picture
  • Member

Posted 09 August 2013 - 10:31 AM

Please tell us what is the problem. What doesn't work anymore?


Amit Shah
  • profile picture
  • Member

Posted 09 August 2013 - 11:49 AM

Well. .. if you see datatables is a totally different theme .. flexrid is a totally different theme... It is technically not possible that you make changes in 1 theme and expect the reflection in other. Its like 2 htmls .. u change in and expect the portion to be reflected in second 1 also.

 

Yes if you change something in the code - grocery_Crud library. .. you can find it in all the themes available. But just by adding it in 1 of the theme, it cannot be pro-claimed to be available in other themes too.. you need to replicate the functionality here in flexigrid to avail it.,


Fabrizio
  • profile picture
  • Member

Posted 09 August 2013 - 12:06 PM

Hello Amit, hello Davidoster :-)

 

thank you for your replies.

I try to explain what's going on.

 

In the file main.php I posted from line 121 onward there the following added functions:

  • update_journal_status --> set the record status to UPD when i update a record
  • insert_journal_status --> set the record status to NEW when i add a record
  • delete_journal_status --> override the real cancellation of the record just setting its status to CANC

I have realized that the last function works. Only I have to refresh the page.

The first two functions appears not to work. They do not set the status which remains empty.

 

All the 3 functions behave like this since when i added on line 29 the code:

 

$crud->set_theme('datatables');

 

to use the datatabel theme instead of flexgrid.

 

I am absolutely a beginner with Grocery Crud. I don't know why all this happens.

Can you possibly help?

 

Thanks a lot in advance!!

 

FAbrizio


davidoster
  • profile picture
  • Member

Posted 09 August 2013 - 12:39 PM

Hello again.

Please be carefull with the way you make your callbacks.

callback_before_update requires at least two (2) parameters.

About the callback_before_insert, on your code you have 

$crud->field_type('stato', 'readonly');

When you use this the library makes sure that you can't update even when you do a callback on the specific field because of the readonly status.

So you need to do a straight change to the database by using the callback_after_insert.

 

P.S. Update: I am not sure that this is not happening on one theme and not on the other. If it does, then the library must have a serious bug somewhere! Please let us know which version of Grocery CRUD you use.


Fabrizio
  • profile picture
  • Member

Posted 09 August 2013 - 12:57 PM

Hello Davidoster,

 

thank you for your advices. Today I can't do that but as soon as i can i'll try to make the needed changes.

As it regards the versions:

 

Codeigniter --> 2.1.3

GroceryCRUD --> 1.3.3

 

I see that there is the 1.4 release. Maybe that an update to it would fix my problem?

 

Fab


davidoster
  • profile picture
  • Member

Posted 09 August 2013 - 13:41 PM

Try first with the version 1.3.3.


Amit Shah
  • profile picture
  • Member

Posted 10 August 2013 - 06:08 AM

Well i will recommend you change the field type of stato from readonly to be hidden. That should solve your trouble.