How can I get a model virtual field to show up as the option text in a select 
generated by the form helper?  Do I have to manually iterate?

Background...  I have a User model identical to the Book example, with a 
virtual field for "name".  Relevant snippet:

var $virtualFields = array(
    'name' => "CONCAT(User.first_name, ' ', User.last_name)"
);
var $hasMany = array(
        'Post' => array(
                'className' => 'Post',
                'foreignKey' => 'user_id',
                'dependent' => false
        )
);
...and of course my Post model belongsTo User.

In posts/add.ctp view, I have a simple form:

<?php echo $form->create('Post');?>
        <fieldset>
                <legend><?php __('Add Post');?></legend>
        <?php
                echo $form->input('user_id');
// ...
        ?>
        </fieldset>
<?php echo $form->end('Submit');?>

Works fine when User.name corresponds to an actual db table, but not when it's 
a virtual field as I have here.  Is it possible to have this show up correctly 
without an actual "name" field?

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to