I have a model called 'project' that uses two fields to create a
project code. I have a 'year' field and a 'code' field. So ie. year
might be 2008 and code might be '112'. In our company everyone refers
to projects by the project code in the format 'YY-NNN' ie. '08-112' in
this case.
I wanted to create a function in my project model called '$project-
>getFormattedCode()' that returned the formatted string. This is call
pretty straight-forward, however how could I then access this function
in a view that lists all projects. As view data is returned as an
array (eg. $project['Project']['code']), is there a way to access this
here. I would need to create a virtual field in the model so that when
a $project->find('all'...) was called it showed up as something like
$project['Project']['fullcode'] or something like that?
I was going to workaround by adding another varchar field in my db
model called 'fullcode' or something to store the formatted ('YY-NNN')
and is updated whenever a project is added/edited, but felt I should
try and do it the correct way first as I am likely to face this again.
Any other suggestions appreciated.
Thanks. Chris.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---