Harsh,
It seems like you are trying to create a tagging system. If so, the Combo Box has this capability out of the box. You can find the widget here: https://marketplace.mendix.com/link/component/219304
To use this widget, you would create a domain model that looks something like this:
Then to use the combo box on a page, configure it like this:
Hope that helps,
Mike
You can also consider using the Label Selector widget. It suggests existing objects and allows to create new ones as tags when needed.
Marketplace Link: Label Selector Widget
Documentation: Label Selector Documentation