# Checkbox on Smart field

**URL:** <https://community.forestadmin.com/t/checkbox-on-smart-field/3574>\
**Category:** Help me!\
**Created:** [October 19, 2021, 2:04pm UTC](https://community.forestadmin.com/t/checkbox-on-smart-field/3574 "2021-10-19T14:04:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cooki23](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cooki23](https://community.forestadmin.com/u/cooki23)\
**Post date:** [October 19, 2021, 2:04pm UTC](https://community.forestadmin.com/t/checkbox-on-smart-field/3574/1 "2021-10-19T14:04:06Z")

</div>

## Expected behavior

I can set the Select Edit Widget of my smart field to be Checkbox

## Actual behavior

Can do Radio Buttons but not Checkbox

## Context

{  
“name”: “foxxbee-admin”,  
“version”: “0.0.1”,  
“private”: true,  
“scripts”: {  
“start”: “node ./server.js”  
},  
“dependencies”: {  
“body-parser”: “1.19.0”,  
“chalk”: “~1.1.3”,  
“cookie-parser”: “1.4.4”,  
“cors”: “2.8.5”,  
“debug”: “~4.0.1”,  
“dotenv”: “~6.1.0”,  
“express”: “~4.17.1”,  
“express-jwt”: “6.0.0”,  
“forest-cli”: “^2.3.5”,  
“forest-express-sequelize”: “^8.0.0”,  
“morgan”: “1.9.1”,  
“pg”: “~8.2.2”,  
“require-all”: “^3.0.0”,  
“sequelize”: “~5.15.1”  
}  
}

---

<div class="post-metadata">

**Author:** ![Sliman\_Medini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/sliman_medini/32/19_2.png) [@Sliman\_Medini](https://community.forestadmin.com/u/Sliman_Medini)\
**Post date:** [October 19, 2021, 2:50pm UTC](https://community.forestadmin.com/t/checkbox-on-smart-field/3574/2 "2021-10-19T14:50:15Z")

</div>

Hi @cooki23,

Can you please share the model definition of this smart field?  
Checkbox is selected by default for Boolean datatypes.

Regards

---

<div class="post-metadata">

**Author:** ![cooki23](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cooki23](https://community.forestadmin.com/u/cooki23)\
**Post date:** [October 20, 2021, 8:01am UTC](https://community.forestadmin.com/t/checkbox-on-smart-field/3574/3 "2021-10-20T08:01:42Z")

</div>

Hey @Sliman_Medini I don’t understand what you mean by model definition for the smart field.  
Perhaps you mean the code that’s responsible for creating it ? In that case you can find it below:

```javascript

const productTagsMap = {
	0: "STYLE",
	1: "COLOR",
	2: "MATERIAL",
	3: "CATEGORY",
	4: "PRODUCT_TYPE",
	5: "ROOM",
	6: "FORM",
	7: "OTHER"
}

const tagTypeFields = getTagTypeFields()

collection('products', {
	actions: [],
	fields: [...tagTypeFields],
	segments: [],
});

function getTagTypeFields() {
	const tagTypes = getTagTypes()
	return tagTypes.map(tagType => {
		let tagTypeName = productTagsMap[tagType]
		return {
			field: `${tagTypeName}_tag`,
			type: 'String',
			get: (product) => displayTagNames(product, tagType),
			set: async (product, tagName) => {
				const productBeforeUpdate = await models.products.findOne({ where: { id: product.id }});
				const updatedTag = await models.tags.findOne({ where: { name: tagName }});
				await productBeforeUpdate.addTag(updatedTag)
				await productBeforeUpdate.save()
				return product
			}
		}
	})
}

async function displayTagNames(product, tagType) {
	let tagNames = ''
	let productTags = await product.getTags()
	productTags.filter(tag => tag.tagType === Number(tagType)).forEach(tag => {
		tagNames += `${tag.name} | `
	})
	return tagNames.slice(0, tagNames.length - 2);
}

function getTagTypes() {
	return Object.keys(productTagsMap)
}

```

Radio buttons are supported, but I want to be able to select multiple options…

 ![Screen Shot 2021-10-20 at 10.01.16 AM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/d/d20704203d7e5a7b06ce42b64e9d32e7455cff22.png)

---

<div class="post-metadata">

**Author:** ![Sliman\_Medini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/sliman_medini/32/19_2.png) [@Sliman\_Medini](https://community.forestadmin.com/u/Sliman_Medini)\
**Post date:** [October 20, 2021, 12:27pm UTC](https://community.forestadmin.com/t/checkbox-on-smart-field/3574/4 "2021-10-20T12:27:37Z")

</div>

What is possible as edit widget on the UI depends on the smart field definition.

When using the type `['String']` (instead of ‘String’) then you will be able to select checkboxes as edit widget.

Regards
