Thankyou for your reply. I tried that but I got an error, I then
however put the following into the properties controller and it looks
like I am closer but it still isn't quite right.

$estates = $this->Property->User->find('all', array('conditions' =>
array('User.group_id' => 4), 'fields' => array( 'Account.id',
'Account.first_name')));

The select is producing the following code now:

<div class="input select"><label for="PropertyEstateId">Estate</
label><select name="data[Property][estate_id]" id="PropertyEstateId">
<option value=""></option>

<option value="first_name">estate</option>
<option value="id">9</option>
<optgroup label="Account">
</optgroup><optgroup label="1">
</optgroup>
<option value="first_name">estatexyz</option>
<option value="id">10</option>
<optgroup label="Account">
</optgroup>
<optgroup label="2">
</optgroup>
<option value="first_name">estateklaka</option>

<option value="id">11</option>
<optgroup label="Account">
</optgroup>
<optgroup label="3">
</optgroup>
<option value="first_name">qq2</option>
<option value="id">24</option>
<optgroup label="Account">
</optgroup>
</select></div>

Ideally i want the first and last name as the option display and the
id as the value.

Thanks


On Jul 5, 5:30 am, Vulinux <[email protected]> wrote:
> Hi elogic.
>
> Since both, Account and Property, belong to User, it should be as easy
> as follows:
>
> In your UsersController (app/controllers/users_controller.php), just
> do
>
>  $this->User->find('all', array('conditions' => array('Users.group_id'
> => 4)));
>
> The method "find('all')" will then return all the associated data of
> your User Object.
>
> Kind regards,
> Vulinux
>
> On 5 Jul., 06:17, elogic <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > I have 3 tables, accounts, users, properties. Within the properties
> > add / edit pages I need to populate two select dropdowns with data
> > from the accounts table however I am not sure how to go about this.
>
> > TABLE INFO (basics)
>
> > ACCOUNTS
> > id
> > first_name
> > last_name
>
> > USERS
> > id
> > username
> > password
> > account_id
> > group_id
>
> > PROPERTIES
> > id
> > name
> > staff_id
> > estate_id
>
> > So both staff_id and estate_id need to have selects using the id
> > first_name and last_name from ACCOUNTS but staff_id will be where
> > group_id in users equals 3 and estate_id = 4.
>
> > The basic SQL should be as follows:
>
> > SELECT accounts.`id`, accounts.`first_name`, accounts.`last_name` FROM
> > accounts, users WHERE accounts.`id` = users.account_id AND
> > users.`group_id` = 4
>
> > Any ideas how I can go about getting this data within my properties
> > controller? I've googled around but I think I am more confused now
> > then before.
>
> > Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to