feat: add :enum attribute type with multi-select UI#15
Merged
somebody32 merged 8 commits intomainfrom Feb 25, 2026
Merged
Conversation
Add two new keyword arguments to the `attribute` class method: - `choices:` — accepts an array or callable. When present, the helper renders a multi-select with checkboxes and a "Select All" toggle instead of a plain text field. Values sync to a hidden field as comma-separated string, so existing strong params work unchanged. - `form_default:` — accepts a value or callable. When the current form value is nil, this default is resolved and used as the input value. Useful for date fields that should show sensible defaults. Both options are stored in `attribute_metadata` (class-level hash) and read by `backfill_option_inputs` at render time. Attributes without these options render exactly as before (backward-compatible). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of using a separate choices: kwarg stored in attribute_metadata, introduce a DataDrip::Types::Enum ActiveModel type. When an attribute is declared as :enum, the type carries its available values and the helper renders a multi-select with "Select All" and "Clear" controls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use ActiveModel's native default: (supports callables) instead of a custom form_default concept. The helper now instantiates the options class to read defaults — zero custom metadata needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- P1: Fix innerHTML/script execution bug - scripts injected via innerHTML
don't execute per HTML5 spec. Add script re-evaluation after insertion.
- P1: Remove global ActiveModel::Type.register(:enum) to avoid namespace
collision. Resolve :enum internally in Backfill.attribute instead.
- P2: Replace .join.html_safe with safe_join() (idiomatic Rails).
- P2: Remove public attr_reader :values_source (internal implementation).
- P2: Remove dead data: { enum_field: field_id } attribute on checkboxes.
- P2: Simplify split regex from /[,;\s]+/ to "," (YAGNI).
- P2: Replace sorted comparison with length check for all_checked.
- P2: Use Tailwind classes instead of inline styles for choices container.
- P3: Fix double DOMContentLoaded initialization in new.html.erb.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Integration Test: Iris::BackfillEntitiesTested locally on the Form Fields Verified:
Specs13 examples, 0 failures (BackfillEntities spec) Video recording saved at |
Contributor
Author
Integration Test: Iris::BackfillEntitiesTested locally on the ScreenshotVideo DemoWatch the full browser test video (13 MB WebM) Form Fields Verified
Specs13 examples, 0 failures ( |
Tailwind classes like max-h-48 are not available when the HTML is injected via innerHTML from an AJAX response (Tailwind purges them). Switch to inline styles to guarantee the scrollable container works. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add search input with magnifying glass icon for filtering options - Add selected count indicator (e.g. "12/20 selected") - Add indeterminate state for "Select All" checkbox - Add hover highlights on checkbox rows - Add "No matches found" empty state - Select All now only toggles visible (filtered) items - Clear button resets both search and selections - Polish spacing, typography, and border radius Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When available_values returns arrays of [label, value] pairs, the component renders the label for display but submits the value to the hidden field. Search matches on the label text. This enables use cases like showing company names while submitting IDs. Backward compatible — plain string arrays still work as before. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sergiocarracedo
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
DataDrip::Types::EnumActiveModel type for multi-select enum attributesattribute :name, :enum, values: [...], the form renders a checkbox group with "Select All" and "Clear" controls instead of a plain text fieldvalues: -> { discover_types })[label, value]pairs — display labels in the UI while submitting values (e.g., show company names, submit IDs)default:for form pre-fill (supports callables like-> { Date.current })Screenshot