⚠ 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

Quick Question



Robert
  • profile picture
  • Member

Posted 29 August 2013 - 12:38 PM

I have a question .. I have 1 field X (date) and i want to create a new field Y that will take the present date and show how many days left until field x date = present day.


Amit Shah
  • profile picture
  • Member

Posted 29 August 2013 - 15:01 PM

Well you can do it.. using javascript.

Hot Linking with javascript opject - on change of the field

Secondly you need to add the field you want to display ... set it read only ..

 

That should do it technically but there is something you need to take care for the same.

You need to override insert / update as there is this extra field (actually you can try without it also as it is read only and should not have much effect on the same)

But in case if there is an issue / error as field not found .. you need to escape insert / update with callback_insert / callback_update

That should do you the trick.!


Robert
  • profile picture
  • Member

Posted 30 August 2013 - 07:30 AM

I see i have one more question .. if i add the code i have for GC tables in a model and then call the model and the function name in a controller is better or leave all in the controller ?


Amit Shah
  • profile picture
  • Member

Posted 31 August 2013 - 08:33 AM

Well even if you do it the with your custom model, no problem with that.... you most welcome to go ahead with the same but the issue here again is... how will it suffice your need to display the number of days remaining @runtime (on change of the field) in the add / edit form. If you want to display it post the add / edit form - u can simply use callback methods ... decide as what you wana do and get the right path acted on.


Robert
  • profile picture
  • Member

Posted 31 August 2013 - 16:23 PM

The second question was not related with the first one. I was jest curious about performance and how it will be best to do.