In CakePHP’s documentation I’ve seen from version 2.2 has been added the configuration key ‘contain’ for the AuthComponent:
The core authentication objects support the following configuration keys.
[…]
contain Containable options for when the user record is loaded.
But I can’ understand how it works (there is no example).
This does not work:
'Auth' => array(
'authenticate' => array(
'Form' => array(
'contain' => array('User' => array('id', 'full_name')),
'fields' => array('username' => 'email'),
)
)
)
Neither this:
'Auth' => array(
'authenticate' => array(
'Form' => array(
'contain' => array('id', 'full_name'),
'fields' => array('username' => 'email'),
)
)
)
Suggestions? Someone tried it?
Contain()is used to contain a DIFFERENT model, not the same one Auth is already retrieving (unless you’re trying to contain other User’s ie their friends or something – but then you’d likely have an alias, and not ‘User’).So, an example would be:
Which would then cause Auth to retreive the user’s Posts as well when it retrieves the user’s data.