Friday, October 3, 2008

Re: Multiple Display Field

I don't understand why this issue still lingers on and on in cakePHP.

Why not just have the following syntax:

(If you only have 1 field)
var $displayField = 'last_name';

(If you have multiple fields)
var $displayField = array(
'fields' = array(
'last_name',
'first_name'),
'pattern' = '%s,%s'
);

That's a concatenation of a number of people's suggestions that have
been floating around for over 3 years. Please tell me something is in
1.2 that facilitates that kind of formatting without resorting to
writing a bunch of extraneous methods for something any application
with users and and admin panel will likely need at some point.

- Keith

On Sep 24, 11:19 am, Kanten <anders.ho...@gmail.com> wrote:
> Well that seems simpler, but I do like the thought of having this as a
> behavior.
>
> /Anders
>
> On Sep 24, 4:29 pm, teknoid <teknoid.cake...@gmail.com> wrote:
>
>
>
> > I'm not familiar with that behavior, but I can offer you another
> > solution, which will work just fine if you need to combine two
> > fields...
>
> >http://teknoid.wordpress.com/2008/09/04/findlist-with-three-or-combin...
>
> > On Sep 24, 9:03 am, Kanten <anders.ho...@gmail.com> wrote:
>
> > > I'm trying to use the Multiple Display Field behavior as described
> > > here:http://bakery.cakephp.org/articles/view/multiple-display-field-3
>
> > > I run into two problems when using this:
> > > 1. Cake generates two error messages whenever I load a page that uses
> > > this behavior:
> > > "SQL Error: 1064: You have an error in your SQL syntax; check the
> > > manual that corresponds to your MySQL server version for the right
> > > syntax to use near 'varDump' at line 1 [CORE\cake\libs\model
> > > \datasources\dbo_source.php, line 512]"
> > > And
> > > "mysqli_real_escape_string() expects parameter 2 to be string, array
> > > given [CORE\cake\libs\model\datasources\dbo\dbo_mysqli.php, line 259]"
>
> > > 2. I cannot figure out how to use a non-existent field as
> > > $display_field. Whenever I try do this I get an error. For instance I
> > > would like to use the field full_name, that isn't in my db table.
>
> > > My code is a folllows:
>
> > > class User extends AppModel {
>
> > >         var $displayField = 'first_name';
>
> > >         var $actsAs = array('MultipleDisplayFields' => array(
> > >         'fields' => array('first_name', 'last_name'),
> > >         'pattern' => '%s %s'
> > >     ));
>
> > > }
>
> > > Anyone?
>
> > > /Anders, Denmark- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: