Conversation
A refactor to make BasedNearFieldBehavior more composable with other
Field Behaviors, and to fix a bug in validates_with.
Two related form-layer fixes:
1. BasedNearFieldBehavior used to handle its own deserialize step
end-to-end. That made it impossible for a second Field Behavior on
the same form to take part in deserialization. The module now lets
Reform handle the standard rename pass first, removes its own key,
and passes control along. Multiple Field Behaviors can now coexist
on one form without conflict.
2. ResourceForm declared its redirects validator with `validates_with`
and a list of attributes. Reform and ActiveModel together end up
sharing one options hash across every form subclass at load time.
ActiveModel empties that hash the first time through, so the second
subclass to load crashed with "attributes cannot be blank." Wiring
the same validator through a `validation { ... }` block instead
gives each subclass its own copy of the options.
Stores redirects as plain hashes on the parent work or collection, mirroring how based_near stores plain URI strings. The previous shape (a set of nested resources) round-tripped badly through Postgres — sub-fields were stripped on save and unrelated parent fields leaked into each entry, leaving the work unloadable. Hyrax::Redirect is kept as a thin presenter the form view uses; other code reads the hash directly. Hyrax.config.redirects_active? becomes the single source of truth for "is the feature in use right now?", combining the config and Flipflop gates. The catch-all redirect route moves to the host application so it no longer intercepts engine routes like /concern/... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3de53ac to
adc28d1
Compare
Adds the Aliases tab to work and collection edit forms when the redirects feature is active. Wires the validator into the form's validation chain so collisions and invalid paths are caught before save. Bridges the form layer to the persisted hash shape via a populator and prepopulator on the resource form.
Adds documentation/forms/field_behaviors.md covering the Field Behavior pattern Hyrax uses for nested-attribute form properties. Explains the contract every behavior must satisfy (registration, deserialize! strip, populator, prepopulator, prepend wiring), the decision points when adding a new one, and uses BasedNearFieldBehavior and RedirectsFieldBehavior as worked examples. Cross-links from documentation/redirects.md and updates the Hyrax::Redirect description there (now a presenter, not a Valkyrie::Resource). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Test Results 17 files 17 suites 3h 25m 53s ⏱️ Results for commit 6c73a4e. ♻️ This comment has been updated with latest results. |
orangewolf
approved these changes
May 6, 2026
Member
orangewolf
left a comment
There was a problem hiding this comment.
onclick for JS in the view isn't my favorite thing, but its small here and the rest of this work is very very good, so I'll let it slide ;-)
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
Adds the Aliases tab to the work and collection edit forms when the redirects feature is active, and wires the validator into the form's validation chain so collisions and invalid paths are caught before save.
Also documents the Field Behavior pattern this work follows, with BasedNearFieldBehavior and RedirectsFieldBehavior as worked examples.
Refs:
RedirectValidator: format, reserved-prefix, cross-tenant uniqueness, multiple-canonical notch8/palni_palci_knapsack#623