Skip to content

Commit 3bd6aab

Browse files
authored
Document optgroup for backend forms dropdown field (#253)
Documents wintercms/winter@8906269
1 parent 6418b6c commit 3bd6aab

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

backend/forms.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,27 @@ status_type:
440440
draft: [Draft, icon-clock-o]
441441
```
442442

443+
#### Add option grouping (optgroup) to dropdown options
444+
445+
In order to add option grouping, use a multidimensional array like below:
446+
447+
```yaml
448+
status_type:
449+
type: dropdown
450+
label: Blog Post Status
451+
options:
452+
Group1:
453+
opt1: Option 1
454+
opt2: Option 2
455+
opt3: Option 3
456+
Group2:
457+
opt4: Option 4
458+
opt5: [Option 5, icon-check-circle]
459+
opt6: Option 6
460+
```
461+
462+
>**NOTE:** individual items in the groups can also use icons or images as shown in "Option 5" above.
463+
443464
To define the behavior when there is no selection, you may specify an `emptyOption` value to include an empty option that can be reselected.
444465

445466
```yaml

cms/themes.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ themes/
307307
```
308308

309309
In this example, when `my-custom-theme` is active:
310+
310311
- `theme.css` and `logo.png` load from the child theme
311312
- `header.htm` loads from the child theme
312313
- `footer.htm` loads from the parent theme (inherited)
@@ -349,49 +350,54 @@ When [database templates](#database-driven-themes) are enabled, you can:
349350
3. Inherit all other files from the parent theme's filesystem
350351

351352
This approach allows you to:
353+
352354
- Manage hundreds of similar themes without duplicating files
353355
- Update the parent theme and have changes cascade to all child themes automatically
354356
- Store tenant-specific customizations in the database while sharing a common codebase
355357

356-
**Example: Creating a virtual child theme**
358+
**Example:** Creating a virtual child theme
357359

358360
1. Enable database templates in `config/cms.php`:
359361

360362
```php
361363
'databaseTemplates' => true,
362364
```
363365

364-
2. Create a theme record in the database with just the `theme.yaml` content:
366+
1. Create a theme record in the database with just the `theme.yaml` content:
365367

366368
```yaml
367369
name: "Client A Custom Theme"
368370
parent: base-theme
369371
```
370372

371-
3. Customize only the templates that need to differ from the parent by saving them to the database
373+
1. Customize only the templates that need to differ from the parent by saving them to the database
372374

373375
The child theme will now function without any physical directory, inheriting everything from `themes/base-theme` except for the database-stored customizations.
374376

375377
### Best Practices
376378

377379
**When to use child themes:**
380+
378381
- Customizing a third-party theme while preserving the ability to update it
379382
- Creating multiple branded variations of a base theme
380383
- Building a multi-tenant application where each tenant needs minor customizations
381384
- Developing a theme framework where a base theme provides core functionality
382385

383386
**When to create a new theme instead:**
387+
384388
- Making extensive changes that affect most templates and assets
385389
- Building something significantly different from the original design
386390
- When you need to modify the theme structure itself
387391

388392
**Organization tips:**
393+
389394
- Keep child themes minimal - only override what's necessary
390395
- Document which files are overridden and why
391396
- Use clear, descriptive names for child themes (e.g., `mytheme-client-a`, `mytheme-blue-variant`)
392397
- Consider using [theme customization](../themes/development#theme-customization) for simple configuration changes before creating a child theme
393398

394399
**Performance considerations:**
400+
395401
- Child themes have minimal performance impact - file resolution is cached
396402
- Avoid deep nesting (grandparent/parent/child) - only one level of inheritance is supported
397403
- Database-driven templates are cached, so virtual child themes perform well

0 commit comments

Comments
 (0)