Craig, Firstly, $event['event']->registerDate() will not work because $event['event'] is an array, not an object.
Secondly, the MVC methodology used by the cakePHP developers discourages you from directly accessing the model from the view. Instead you should call canRegister and registerDate from the controller and then pass the information onto the view, or use a helper. Read the manul for more info about helpers. That said, many people are not satisfied with that degree of separation. There are several threads about this topic. Here is a recent one: http://groups.google.com/group/cake-php/browse_thread/thread/57bca638ed0dd0a/6b86038d4b9b9afa?hl=en#6b86038d4b9b9afa The entry by "Felix Geisendörfer" (IMHO) describes the best route for accessing model functions from the view. Do some searching and you will find many other related threads. For you particular case, I would recommend using the afterFind method in your model. That way the registration data will always be available to you. class Event extends AppModel{ ... function afterFind($results) { foreach ($results as $result) { //add code here to add your registration data to the output array. } return $results; } ... } Look at the afterFind method in the manual (http://manual.cakephp.org/ chapter/models) and in the api (http://api.cakephp.org/ class_model.html#21de65cdbc08ce706a9413b4c73f28c5). Good luck, cook On Jun 4, 9:00 am, Craig <[EMAIL PROTECTED]> wrote: > Hi All, > > I have searched and I can't find an answer anywhere so I ask the > question... > > I would like to display and use derived values in a view.... > > The model knows how to calculate these values form it's own data.. but > how do I call these methods in a view.. > > For example I have a model called event I have defined 2 methods > canRegister and regsiterDate > > Can register returns true if a user can register for the event and > registerDate returns the date that registrations open... > > I would like the list (index.thtml) to display the regiser date if you > can't register and a link if you can... > > however I can't see to call these methods from the view?? > > I tried echo $event['event']->registerDate() but it didn't work... > I don't want to store the register date in the database as in the > event of a rule change I want to update the model and not have to > patch all the data for existing events. > an y help would be greatly appreciated. > > Craig. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
