- Radio and checkbox groups via
Field(:plan).radios(...)andField(:roles).checkboxes(...). Return renderable Phlex components (likeinput,select) so they work as one-liners via Kit. Without a block, renders default<label><input> Text</label>markup per choice. With a block, yields eachChoicefor custom markup —choice.inputandchoice.labelrender directly into the component's output. Accepts the same option formats asselect. Auto-detects Rails enums when called with no arguments.choice.labelwithout a block defaults to renderingchoice.text. SubclassComponents::RadiosorComponents::Checkboxesto customize defaults. - Hash options for
select,radios, andcheckboxes— e.g.radios(1 => "Basic", 2 => "Pro"). - Radio component with
field(:gender).radio("male")API. Automatically handles name, value, and checked state. Each radio gets a unique DOM id based on its value (e.g.user_gender_male). - Checkbox collection support — three modes:
- Boolean (on/off toggle):
Field(:featured).checkboxrenders with hidden "0" input - All-options (pick from known set):
Field(:role_ids).checkbox(value: role.id)with[]name and unique ids per value - Field collection (from existing array):
field(:role_ids).collection { |r| r.checkbox }for values already on the model
- Boolean (on/off toggle):
- Choices module (
Superform::Rails::Choices) —Choices::Choiceholds per-option state,Choices::Mapper(renamed fromOptionMapper) maps option args to(value, text)pairs. - Unique DOM ids for radio and checkbox groups via
DOM#id(*suffixes). Prevents duplicate ids in valid HTML and allows labels to target individual inputs. - Datalist component with
Field(:time_zone).datalist(*ActiveSupport::TimeZone.all.map(&:name)). Renders a native<input>+<datalist>for free-text input with autocomplete suggestions — no JavaScript required. Accepts the same option formats asselect. Block form available for custom options. - Select improvements: blank options (
nil) at any position,multiple: truesupport with hidden input for empty submissions, ActiveRecord relations as options. - Preview server — run
bin/previewto view example forms at localhost:3000 with hot-reloading.
-
OptionMapperrenamed toChoices::Mapper. If you referencedSuperform::Rails::OptionMapperdirectly, update toSuperform::Rails::Choices::Mapper. -
Deprecation: Components now accept HTML attributes as keyword arguments directly instead of wrapping them in
attributes:. The oldattributes:keyword still works but emits a deprecation warning and will be removed in a future version.# Before MyInput.new(field, attributes: { class: "form-input" }) # After MyInput.new(field, class: "form-input")
If you have custom components that override
initialize, update them to use**attributes:# Before class MyRadio < Superform::Rails::Components::Field def initialize(field, value:, attributes: {}) super(field, attributes: attributes) @value = value end end # After class MyRadio < Superform::Rails::Components::Field def initialize(field, value:, **attributes) super(field, **attributes) @value = value end end
-
Required Ruby version bumped to 2.7.0.
This release includes several breaking changes to improve consistency with Phlex 2.x conventions and better organize the codebase.
The framework now passes form instances instead of field classes throughout the namespace hierarchy:
Namespaceconstructor now acceptsform:parameter instead offield_class:NamespaceCollectionconstructor now acceptsform:parameter instead offield_class:- Form instances must implement a
build_fieldmethod for field creation - Rails forms now pass themselves as form instances to namespaces
This change enables better encapsulation and allows forms to customize field creation logic.
All Rails component classes have been renamed to match Phlex 2.x conventions by removing the "Component" suffix:
Superform::Rails::Components::BaseComponent→Superform::Rails::Components::BaseSuperform::Rails::Components::FieldComponent→Superform::Rails::Components::FieldSuperform::Rails::Components::InputComponent→Superform::Rails::Components::InputSuperform::Rails::Components::ButtonComponent→Superform::Rails::Components::ButtonSuperform::Rails::Components::CheckboxComponent→Superform::Rails::Components::CheckboxSuperform::Rails::Components::TextareaComponent→Superform::Rails::Components::TextareaSuperform::Rails::Components::SelectField→Superform::Rails::Components::SelectSuperform::Rails::Components::LabelComponent→Superform::Rails::Components::Label
Rails classes have been moved into separate files for better organization:
- Components are now in individual files under
lib/superform/rails/components/ - Core classes like
Formare now inlib/superform/rails/form.rb
- Now requires
phlex-rails ~> 2.0(was>= 1.0, < 3.0)
The ApplicationForm file should be moved to Components::Form at ./app/components/form.rb to better match Phlex 2.x conventions.
# Before (0.5.x)
class ApplicationForm < Superform::Rails::Form
# ...
end# After (0.6.0)
class Components::Form < Superform::Rails::Form
# ...
endForm variants may organized in the ./app/components/forms/ directory.
# Before (0.5.x)
class Forms::User < ApplicationForm
# ...
end# After (0.6.0)
class Forms::User < Components::Form
# ...
endCustom form classes with Rails now automatically pass themselves as form instances (no changes needed for basic usage).
Update component class names in your custom form classes:
# Before (0.5.x)
class MyInput < Superform::Rails::Components::InputComponent
# ...
end
class Field < Superform::Rails::Form::Field
def input(**attributes)
MyInput.new(self, attributes: attributes)
end
end# After (0.6.0)
class MyInput < Superform::Rails::Components::Input
# ...
end
class Field < Superform::Rails::Form::Field
def input(**attributes)
MyInput.new(self, **attributes)
end
endUpdate your Gemfile to ensure compatibility:
gem 'phlex-rails', '~> 2.0'
gem 'superform', '~> 0.6.0'Run bundle update to update dependencies:
bundle update phlex-rails superform- Form instance architecture for better encapsulation and customization
Superform::Formclass for basic form behavior without Rails dependenciesbuild_fieldmethod delegation to form instances- Better file organization with Rails classes in separate files
- Improved Phlex 2.x compatibility and conventions
- Strong Parameters support with
Superform::Rails::StrongParametersmodule:permit(form)method for assigning permitted params without savingsave(form)method for saving models with permitted paramssave!(form)method for saving with exception handling on validation failure- Automatic parameter filtering based on form field declarations
- Safe mass assignment protection against unauthorized attributes
- Field input type helper methods for Rails forms:
field.emailfor email input typefield.passwordfor password input typefield.urlfor URL input typefield.tel(withphonealias) for telephone input typefield.numberfor number input typefield.rangefor range input typefield.datefor date input typefield.timefor time input typefield.datetimefor datetime-local input typefield.monthfor month input typefield.weekfor week input typefield.colorfor color input typefield.searchfor search input typefield.filefor file input typefield.hiddenfor hidden input typefield.radio(value)for radio button input type
- Breaking:
NamespaceandNamespaceCollectionconstructors now acceptform:instead offield_class: - Breaking: Form instances must implement
build_fieldmethod - Rails component classes moved to individual files
- Component class names simplified to match Phlex conventions
- Dependency updated to require phlex-rails 2.x
- Initial release