# Express - Programmatically Add Select, and set Options List

**URL:** https://forums.concretecms.org/t/express-programmatically-add-select-and-set-options-list/5858
**Category:** Developing with Concrete
**Created:** [July 4, 2023, 10:43am UTC](https://forums.concretecms.org/t/express-programmatically-add-select-and-set-options-list/5858 "2023-07-04T10:43:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![BloodyIron](https://forums.concretecms.org/user_avatar/forums.concretecms.org/bloodyiron/32/3807_2.png) [@BloodyIron](https://forums.concretecms.org/u/BloodyIron)
#### Post date: [July 4, 2023, 10:43am UTC](https://forums.concretecms.org/t/express-programmatically-add-select-and-set-options-list/5858/1 "2023-07-04T10:43:46Z")

</div>

Hey so I’m trying to figure out the correct steps for setting the Options List when adding an Attribute of type Select to an Express Object I’m building Programmatically… and falling on my face trying to figure it out… Can anyone help me please? This is what I have so far

```
        $object = Express::buildObject('test1', 'test1', 'Test1');
        $object->addAttribute('user_selector', 'Owner User', 'test_owner');
        $settings = new \Concrete\Core\Entity\Attribute\Key\Settings\SelectSettings();
        $settings->setAllowMultipleValues(false);
        $settings->setDisplayMultipleValuesOnSelect(false);
        $settings->setHideNoneOption(true);
        $settings->setAllowOtherValues(false);
        $list = ['test1', 'test2'];
        $optionList = new \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOptionList();
        $optionList->setOptions($list);
        $settings->setOptionList($optionList);
        $object->addAttribute('select', 'Test Select', 'test_select', $settings);
        $object->save();

```

---

<div class="post-metadata">

### Author: ![BloodyIron](https://forums.concretecms.org/user_avatar/forums.concretecms.org/bloodyiron/32/3807_2.png) [@BloodyIron](https://forums.concretecms.org/u/BloodyIron)
#### Post date: [July 4, 2023, 12:21pm UTC](https://forums.concretecms.org/t/express-programmatically-add-select-and-set-options-list/5858/2 "2023-07-04T12:21:51Z")

</div>

I’ve just wasted so many hours trying to figure out how to add/edit/remove or whatever options for this, and I really think I need help.

---

<div class="post-metadata">

### Author: ![hissy](https://forums.concretecms.org/user_avatar/forums.concretecms.org/hissy/32/5107_2.png) [@hissy](https://forums.concretecms.org/u/hissy)
#### Post date: [July 6, 2023, 11:24am UTC](https://forums.concretecms.org/t/express-programmatically-add-select-and-set-options-list/5858/3 "2023-07-06T11:24:16Z")

</div>

@BloodyIron

I think you’re using setOptions in a wrong way.

```auto
$list = ['test1', 'test2'];
$optionList = new \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOptionList();
foreach ($list as $i => $value) {
    $option = new \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption();
    $option->setSelectAttributeOptionValue($value);
    $option->setOptionList($optionList);
    $option->setDisplayOrder($i);
    $optionList->getOptions()->add($option);
}
$settings->setOptionList($optionList);

```

---

<div class="post-metadata">

### Author: ![BloodyIron](https://forums.concretecms.org/user_avatar/forums.concretecms.org/bloodyiron/32/3807_2.png) [@BloodyIron](https://forums.concretecms.org/u/BloodyIron)
#### Post date: [July 6, 2023, 11:51am UTC](https://forums.concretecms.org/t/express-programmatically-add-select-and-set-options-list/5858/4 "2023-07-06T11:51:51Z")

</div>

WOOO THIS WORKED TOO! And yeah, I know I was using it in a wrong way, but I couldn’t tell how I _should_ use it, hah! Thanks again! 😃
