Skip to content

refactor!: render the form buttons via overridable views - #6791

Merged
gharlan merged 2 commits into
6.xfrom
form-button-view
Oct 21, 2026
Merged

gharlan merged 2 commits into
6.xfrom
form-button-view

Conversation

@gharlan

@gharlan gharlan commented Oct 21, 2026

Copy link
Copy Markdown
Member

Follow-up to #6787: the form buttons were the last part of the form system with markup hard-coded in Form (btn … classes, accesskeys, rex-form-aligned), so they couldn't be restyled for the frontend.

  • New widgets Button, CancelLink and ButtonToolbar, each with its own view. Since they live under Redaxo\Core\Form, ViewResolver::overrideNamespace('Redaxo\Core\Form', …) covers them as well.
  • SubmitButton::$class (a Bootstrap class) → SubmitButton::$style with the new ButtonStyle enum (Primary, Secondary, Danger). The backend view maps it to btn-save/btn-default/btn-delete; the button named apply keeps btn-apply, because standard.js clicks that one on cmd+enter.
  • Alignment with the field column is a toolbar concern, not a button property: Form::buttons() now renders the whole toolbar including the btn-toolbar wrapper, and its backend view aligns the first button. Form::button() takes html attributes instead of the aligned flag (custom markup passes ['class' => ['rex-form-aligned']]).
  • accesskey stays on the button: it states the button's intent, the backend view turns it into the actual key (new Accesskey::get()), other views can ignore it.

Breaking: SubmitButton(class: …) → style: ButtonStyle::…, Form::button($name, aligned: true) → attributes, and callers no longer wrap Form::buttons() in .btn-toolbar.

The submit buttons, the cancel link and the toolbar wrapping them are rendered by the new widgets `Button`,
`CancelLink` and `ButtonToolbar` with their own views instead of markup hard-coded in `Form`, so they can be
restyled like the other form views (e.g. for the frontend via `ViewResolver::overrideNamespace()`).

- `SubmitButton::$class` is replaced by the semantic `SubmitButton::$style` (`ButtonStyle::Primary`/`Secondary`/
  `Danger`); the backend view maps it to the css classes.
- `Form::buttons()` renders the whole toolbar including the `btn-toolbar` wrapper; the backend view aligns the
  first button with the field column.
- `Form::button()` takes html attributes instead of the `aligned` flag.
- `Accesskey::get()` returns the accesskey for a key.
@gharlan gharlan added this to the REDAXO 6.0 milestone Oct 21, 2026
@gharlan
gharlan merged commit d9754fe into 6.x Oct 21, 2026
15 checks passed
@gharlan
gharlan deleted the form-button-view branch October 21, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants