Skip to content

[Admin] Solidus form builder#6294

Merged
tvdeyen merged 22 commits intosolidusio:mainfrom
chaimann:admin-form-builder
Aug 5, 2025
Merged

[Admin] Solidus form builder#6294
tvdeyen merged 22 commits intosolidusio:mainfrom
chaimann:admin-form-builder

Conversation

@chaimann
Copy link
Contributor

Summary

Adds a convenient SolidusAdmin::FormBuilder with shortcuts for all currently used form elements, such as:

  • raw input field
  • text field (with labels etc.)
  • hidden field
  • text area
  • select
  • checkbox
  • checkbox row
  • switch field
  • submit button

Before:

form_for(@product, ...) do |f|
  render component("ui/forms/field").text_field(f, :name)

After:

solidus_form_for(@product, ...) do |f|
  f.text_field(:name)

Lots of boilerplate code and logic is now contained in the builder, e.g. object name and "checked" attribute for checkboxes:

# before
form_for(@product, ...) do |f|
  render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active)

# after
solidus_form_for(@product, ...) do |f|
  f.checkbox(:active)

Submit button together with UI/Button's component #submit has now become a powerful "no-args-required" thing - component chooses a correct button text depending on a record passed to the form builder.
So this:

render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')

becomes this:

f.submit

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

@github-actions github-actions bot added changelog:solidus_admin changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Jun 23, 2025
@chaimann chaimann force-pushed the admin-form-builder branch 2 times, most recently from 8cca352 to d6b3932 Compare June 24, 2025 10:47
@codecov
Copy link

codecov bot commented Jun 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.33%. Comparing base (da70045) to head (31952bb).
⚠️ Report is 28 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6294      +/-   ##
==========================================
+ Coverage   89.31%   89.33%   +0.02%     
==========================================
  Files         959      961       +2     
  Lines       20117    20157      +40     
==========================================
+ Hits        17968    18008      +40     
  Misses       2149     2149              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chaimann chaimann force-pushed the admin-form-builder branch from d6b3932 to fa4fca7 Compare June 24, 2025 11:23
@chaimann chaimann marked this pull request as ready for review June 24, 2025 17:24
@chaimann chaimann requested a review from a team as a code owner June 24, 2025 17:24
@chaimann chaimann mentioned this pull request Jul 5, 2025
4 tasks
Copy link
Member

@adammathys adammathys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. ❤️

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this PR.

Copy link
Contributor

@benjaminwil benjaminwil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this

@tvdeyen tvdeyen force-pushed the admin-form-builder branch from 32c2509 to 31952bb Compare August 5, 2025 12:00
@tvdeyen tvdeyen enabled auto-merge August 5, 2025 12:00
@tvdeyen tvdeyen moved this to Review in Solidus Admin Aug 5, 2025
@tvdeyen tvdeyen added this to the 4.6 milestone Aug 5, 2025
@tvdeyen tvdeyen merged commit e5930a6 into solidusio:main Aug 5, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Review to Done in Solidus Admin Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_admin changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants