Have you tried debugging this yourself - what problems did you
encounter?  The errors above give you specific line numbers in your
own code that should give a good idea what is happening.

For a guess, since it is in your afterFind, you are expecting the
afterFind to have an array of results each with a $this->name key,
e.g.
$results = array(  array('Professor'=>array(....)),
array('Professor'=>array(....)) )

which is the case when the model is the primary one being queried.
When the model is only associated to the model being queried, then you
may get an array with a single $this->name key, under which is a
numerically indexed array of results, e.g.

$results = array( 'Professor'=>array(  0=>array(...), 1=>array(...),
2=>array(...) ));

So, your afterFind needs to be a bit smarter.  Personally, I have the
following in my app_model:

        function afterFind( $results )
        {
                // see if the model wants to attach attributes
                if ( method_exists($this, '_attachAttributes') ){
                        for ($i = 0; $i < sizeof($results); $i++) {
                                // check if this is a model, or if it is an 
array of models
                                if ( isset($results[$i][$this->name]) ){
                                        // this is the model we want, see if 
it's a single or array
                                        if ( 
isset($results[$i][$this->name][0]) ){
                                                // run on every model
                                                for ($j = 0; $j < 
sizeof($results[$i][$this->name]); $j++) {
                                                        
$this->_attachAttributes( &$results[$i][$this->name][$j] );
                                                }
                                        } else {
                                                $this->_attachAttributes( 
&$results[$i][$this->name] );
                                        }
                                }
                        }
                }

                return $results;
        }

and then in my model class I would have something like:

        function _attachAttributes( $row )
        {
                if ( isset($row['firstname']) and isset($row['surname']) ){
                        $row['fullname'] = $row['firstname'].' 
'.$row['surname'];
                }
        }


But if you really just want a select with the two fields, just do it
by hand:

        function niceSelect( $conditions )
        {
                $select_list = array();

                $rows = $this->findAll( $conditions, null, null null, 1, -1 );
                if ( !empty($rows) ){
                        foreach( $rows as $row ){
                                $select_list[ $row[$this->name]['id'] ] = 
$row[$this->name]
['firstname'].' '.$row[$this->name]['surname'];
                        }
                }

                return $select_list;
        }



On Nov 21, 9:41 pm, dandreta <[EMAIL PROTECTED]> wrote:
> Thanks for your response, but this doesn't solve the problem.
> I don't know what to do.
> Do you know another way of showing two fields
> joined in a select?
>
> On 20 nov, 22:56, francky06l <[EMAIL PROTECTED]> wrote:
>
> > I do not know if this can be a hint ... I have had the same problem
> > recently (working from the SVN branch).. Again I am not sure, but this
> > was linked to a Cache::config that had a "serialize" => false, in my
> > core.php.
> > I am quite sure it's not related, but .... might be a track :
>
> >http://groups.google.com/group/cakephp-edge/browse_thread/thread/d127...
>
> > cheers
>
> > On Nov 20, 8:20 pm, dandreta <[EMAIL PROTECTED]> wrote:
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to