This can be done like the Controller method?

class NameController extends AppController {
    // .... code
    function beforeFilter() {
        // ... code
    }
}

If not, then add

function __construct($id = false, $table = null, $ds = null) {
{
parent::__construct($id, $table, $ds);
$this->actual_year = date('Y');
}
---

Norman Paniagua


2010/7/22 ohcibi <[email protected]>

> Read about overriding inherited methods, especially the constructor
> (e.g. in almost every case you have to call the parents constructor,
> to initialize the object correctly)... Theres a special node in
> model.php regarding overwriting the models constructor
> http://api.cakephp.org/view_source/model/#l-371
>
> On 22 Jul., 17:26, "Mariano C." <[email protected]> wrote:
> > I've addedd:
> > 4        var $actual_year;
> > 5
> > 6               public function __construct()
> > 7        {
> > 8               $this->actual_year = date('Y');
> > 9         }
> >
> > and I get:
> >
> > Warning: Unexpected character in input: ' ' (ASCII=29) state=1 in /
> > Applications/MAMP/htdocs/cakephp/app/models/album.php on line 9
> > Fatal error: Call to a member function trigger() on a non-object in /
> > Applications/MAMP/htdocs/cakephp/cake/libs/model/model.php on line
> > 2066
> >
> > On 22 Lug, 16:57, ohcibi <[email protected]> wrote:
> >
> >
> >
> > > You are not allowed to use functions in class variable definitions,
> > > you could do this in Post::_construct(). This is a php restriction
> >
> > > On 22 Jul., 16:45, "Mariano C." <[email protected]> wrote:
> >
> > > > <?php
> > > > class Post extends AppModel
> > > > {
> > > >         var $name = 'Post';
> > > >         var $hasAndBelongsToMany = 'Tag';
> >
> > > >         var $actual_year = date('Y');
> >
> > > >         $validate = array
> > > >         (
> > > >             'year' => array
> > > >             (
> > > >                 'required' => true,
> > > >                 'rule' => array('range', 1899, $actual_year),
> > > >                 'message' => 'Insert a number between 1899 and '.
> > > > $actual_year
> > > >             )
> > > >         );}
> >
> > > > ?>
> >
> > > > But I get a stupid error on line 7: Parse error: syntax error,
> > > > unexpected '(', expecting ',' or ';' in /Applications/MAMP/htdocs/
> > > > cakephp/app/models/album.php on line 7
> >
> > > > Why?
> > > > Parse error: syntax error, unexpected '(', expecting ',' or ';' in /
> > > > Applications/MAMP/htdocs/cakephp/app/models/album.php on line 7
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to