# Howto get associated fields as options in a form and not the id field only?

**URL:** <https://discourse.cakephp.org/t/howto-get-associated-fields-as-options-in-a-form-and-not-the-id-field-only/8929>\
**Category:** Need Help\
**Tags:** behavior\
**Created:** [January 30, 2021, 3:52pm UTC](https://discourse.cakephp.org/t/howto-get-associated-fields-as-options-in-a-form-and-not-the-id-field-only/8929 "2021-01-30T15:52:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eMarcus](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@eMarcus](https://discourse.cakephp.org/u/eMarcus)\
**Post date:** [January 30, 2021, 3:52pm UTC](https://discourse.cakephp.org/t/howto-get-associated-fields-as-options-in-a-form-and-not-the-id-field-only/8929/1 "2021-01-30T15:52:51Z")

</div>

Hi there,

This might be a very stupid question from a newbie on CakePHP 4 (I did some work on CakePHP 2 years ago and this was never a problem as far as I remember), but although I consulted the tutorial carefully, I don’t get it done!

I have a table “Earnings” with the following fields:  
id  
date  
customer\_id  
description  
amount

and a corresponding “Customer” table where I store my clients  
id  
fullname

Now, when I add a new earning, I want to be able to select the customer by its fullname and not by its id. However, the scaffolded “add” function only provides me the customer\_id in the form and not the fullname.

The template line for the form looks like this:  
`echo $this->Form->control('customer_id', ['options' => $customers]);`

How can I change the options to get the fullname field instead of the id field in the dropdown list?

Thanks for your help!  
Marcus.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [January 30, 2021, 4:41pm UTC](https://discourse.cakephp.org/t/howto-get-associated-fields-as-options-in-a-form-and-not-the-id-field-only/8929/2 "2021-01-30T16:41:26Z")

</div>

In `CustomersTable::initialize`, use `$this->displayField('fullname');`
