Skip to content

fix(bootstrap-admin-ui): pick the form method from the page instead of the resource id - #394

Open
Rafikooo wants to merge 1 commit into
Sylius:mainfrom
Rafikooo:fix/create-form-method-for-preset-id
Open

Rafikooo wants to merge 1 commit into
Sylius:mainfrom
Rafikooo:fix/create-form-method-for-preset-id

Conversation

@Rafikooo

@Rafikooo Rafikooo commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

The CRUD form decides between POST and PUT by looking at form.vars.data.id. A resource whose id is assigned in the constructor (UUID/ULID generated up front) already has an id on the create page, so the create form gets <input name="_method" value="PUT">. With http_method_override on, the submit hits the create route as PUT and fails with a 405.

Page Resource id Before After
create null POST POST
create preset in constructor PUT POST
update any PUT PUT

The page knows which operation it renders, so crud/create.html.twig and crud/update.html.twig now pass form_method in the hook context and the form template reads it. Precedence stays configuration.method (hookable config) first. The id check remains only as a fallback for apps that override the page templates and don't pass form_method.

FormMethodTest covers it: the test app's BookResource create operation now uses a factory that presets the id. The test fails before the change and passes after it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant