Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorsuthern
     
    Don't let the subject confuse you.

    I know I've run into a solution before, but the searching on this forum doesn't read my mind correctly. :-)

    I have a model called 'Person'. This model has fields first_name and last_name.

    I'd like a new variable called 'full_name' that is simply first_name, a space, and last_name.

    I'd like to be able to access this variable for dropdown menus and such. What would you do?

    If I try to declare "var $full_name = $this->first_name . ' ' . $this->last_name;" PHP throws an error about variables in declarations.
    • CommentAuthorsuthern
     

    And a solution to my own problem!!

    In my config.php I added this: define('AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS', true);

    Then in the model I added this function: function getFullName() { return $full_name = $this->first_name . " " . $this->last_name; }

    Now I can call $Person->get("full_name"), and it works! :-)

    • CommentAuthordemaio
     
    he he ... nifty trick ;]
    • CommentAuthordelia
     
    You can also use the property $combined_attributes like it is explained here: <a href="http://forum.akelos.org/discussion/222/">http://forum.akelos.org/discussion/222/</a>
    • CommentAuthorsuthern
     

    Ooo, $combined_attributes is even slicker. :-)