Okay, the first thing to do would be to check the output in the
controller, i.e. pr($types).
Second, make sure you're actually *sending* the types var to the view,
i.e. $this->set("types", $types); or $this->set(compact("types"));
Third, check it in your view file (same code as step 1, just move it
to the template).
Fourth, if all else fails, set it manually: $form->input("type_id",
array("options" => $types));
On Feb 12, 1:36 pm, cartosys <[EMAIL PROTECTED]> wrote:
> Ok, spent many hours looking for appropriate syntax for the formhelper
> and controller in 1.2 for this (looked in manuals, API, groups, blogs
> etc.). I've decided that I will donate $10 if this issue is resolved!
>
> here's the tables:
>
> urls_users
> +-----------------+------------------+------+-----+---------
> +----------------+
> | Field | Type | Null | Key | Default |
> Extra |
> +-----------------+------------------+------+-----+---------
> +----------------+
> | id | int(10) unsigned | NO | PRI | NULL |
> auto_increment |
> | type_id | int(10) unsigned | NO | MUL | 1
> | |
> | description | blob | YES | | NULL
> | |
> | created | datetime | YES | | NULL
> | |
> | modified | datetime | YES | | NULL
> | |
> +-----------------+------------------+------+-----+---------
> +----------------+
>
> belongsTo:
>
> types
> +-------+------------------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-------+------------------+------+-----+---------+----------------+
> | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
> | type | varchar(20) | YES | | NULL | |
> +-------+------------------+------+-----+---------+----------------+
>
> I've baked an 'add' view using urls_users with a form in which I want
> a select box populated with Type.type. The default bake does
> everything I want except lists the Type.id instead of Type.type. Here
> are the controller elements and formhelper stuff:
>
> //controller
> $types = $this->UrlsUser->Type-
>
> >find('list',array('fields'=>array('Type.id','Type.type')));
>
> //view
> echo $form->input('type_id');
>
> So i modified the controller arguments to include Type.type since the
> default find('list') only returned numerical id's. The resulting
> query, as displayed at the bottom of the default page view (by the
> paginater?),
>
> "SELECT `Type`.`id`, `Type`.`type` FROM `types` AS `Type` WHERE 1 =
> 1"
>
> does yield the desired results in mysql:
>
> +----+-----------+
> | id | type |
> +----+-----------+
> | 1 | Masculine |
> | 2 | Feminine |
> +----+-----------+
>
> So I figure I'm missing some syntax either in the view or controller
> at or near the above mentioned lines (as far as I can tell). Any help
> on how this associated data can be displayed in the selectbox?
>
> Thx,
> -B
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---