A small plugin for Frappe that adds the support of option groups to the select control.
- Frappe >= v13.0.0
Do not forget to replace [sitename] with the name of your site in all commands.
- Go to bench directory
cd ~/frappe-bench
- Get plugin from Github
(Required only once)
bench get-app https://github.com/kid1194/frappe-better-select-control
- Build plugin
(Required only once)
bench build --app frappe_better_select_control
- Install plugin on a specific site
bench --site [sitename] install-app frappe_better_select_control
- Go to app directory
cd ~/frappe-bench/apps/frappe_better_select_control
- Get updates from Github
git pull
- Go to bench directory
cd ~/frappe-bench
- Build plugin
bench build --app frappe_better_select_control
- Update a specific site
bench --site [sitename] migrate
- (Optional) Restart bench
bench restart
- Go to bench directory
cd ~/frappe-bench
- Uninstall plugin from a specific site
bench --site [sitename] uninstall-app frappe_better_select_control
- Remove plugin from bench
bench remove-app frappe_better_select_control
- (Optional) Restart bench
bench restart
- Go to Customization > Customize Form
- Enter the form type/name (ex: 'User')
- Scroll down to the form fields area and edit the select fields you want
- In the options property of the fields, add a hashtag (#) before the option text to make it a group label
- To close a group just add a single hashtag (#) in a new line
- Add an exclamation mark ! before a hashtag (#) at the beginning of the option text to stop it from being used as a group label
You can't modify the original fields of a doctype, so create a new field or clone and modify the entire doctype.
- Options:
One
Two
#Three
Four
Five
- Result HTML:
<option value="One">One</option>
<option value="Two">Two</option>
<optgroup label="Three">
<option value="Four">Four</option>
<option value="Five">Five</option>
</optgroup>
- Options:
#One
Two
Three
#Four
Five
Six
- Result HTML:
<optgroup label="One">
<option value="Two">Two</option>
<option value="Three">Three</option>
</optgroup>
<optgroup label="Four">
<option value="Five">Five</option>
<option value="Six">Six</option>
</optgroup>
- Options:
One
Two
#Three
Four
Five
#
Six
- Result HTML:
<option value="One">One</option>
<option value="Two">Two</option>
<optgroup label="Three">
<option value="Four">Four</option>
<option value="Five">Five</option>
</optgroup>
<option value="Six">Six</option>
- Options:
One
Two
#
Three
Four
Five
#
Six
- Result HTML:
<option value="One">One</option>
<option value="Two">Two</option>
<optgroup label="">
<option value="Three">Three</option>
<option value="Four">Four</option>
<option value="Five">Five</option>
</optgroup>
<option value="Six">Six</option>
- Options:
$Select..
One
Two
#Three
Four
Five
#
Six
- Result HTML:
<option value="" disabled hidden selected>Select...</option>
<option value="One">One</option>
<option value="Two">Two</option>
<optgroup label="Three">
<option value="Four">Four</option>
<option value="Five">Five</option>
</optgroup>
<option value="Six">Six</option>
If you find bug in the plugin, please create a bug report and let us know about it.
MIT