# Convert Checkboxes to Dropdown?

**URL:** <https://discourse.cakephp.org/t/convert-checkboxes-to-dropdown/10905>\
**Category:** Need Help\
**Created:** [January 17, 2023, 10:17pm UTC](https://discourse.cakephp.org/t/convert-checkboxes-to-dropdown/10905 "2023-01-17T22:17:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/alexd/32/2587_2.png) [@alexd](https://discourse.cakephp.org/u/alexd)\
**Post date:** [January 17, 2023, 10:17pm UTC](https://discourse.cakephp.org/t/convert-checkboxes-to-dropdown/10905/1 "2023-01-17T22:17:11Z")

</div>

Hi,  
I have an admin page (created by someone else) that includes checkboxes. These are each linked to separate columns in the database, but our app requires only ONE of these options to be selected. I am not sure why they (previous developer) would not have used a dropdown list and one value/column in the database, but this is what I have to work with. How can I (or can I?) convert this into a dropdown? If not, is there a way to add validation to require at least one (and at most one) of the options to be selected?  
Thanks,  
Alex.

 ![user-checkboxes](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/b/b34ec85b1825d085a70a9ca5065855a488f5eafb.jpeg)

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [January 18, 2023, 3:29pm UTC](https://discourse.cakephp.org/t/convert-checkboxes-to-dropdown/10905/2 "2023-01-18T15:29:43Z")

</div>

the first param of `$this->Form->input()` is the name of the input you want to create.  
So here you have 4 different checkboxes with 4 different `name` values inside your form which therefore will be submitted with those 4 names to Cake when you submit that form.

Usually in Cake you will have 1 input field per column, so in your case the first thing I would check is if you have 4 columns in your table which are called `surgical`, `paediatric` etc.

Regarding generating a dropdown:  
In the end you will need something like

```auto
$this->Form->select('my_new_name', [
    'surgical' => 'Surgeon',
    'paediatric' => 'Physician'
    // etc.
]);

```

which will then be available in your controller via

```auto
$data = $this->getRequest()->getData('my_new_name');

```

---

<div class="post-metadata">

**Author:** ![alexd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/alexd/32/2587_2.png) [@alexd](https://discourse.cakephp.org/u/alexd)\
**Post date:** [January 18, 2023, 7:43pm UTC](https://discourse.cakephp.org/t/convert-checkboxes-to-dropdown/10905/3 "2023-01-18T19:43:45Z")

</div>

Thanks,  
That gives me something to work with. 😀
