Class: Hyrax::Forms::FailedSubmissionFormWrapper Deprecated
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Hyrax::Forms::FailedSubmissionFormWrapper
- Defined in:
- app/forms/hyrax/forms/failed_submission_form_wrapper.rb
Overview
This class should be removed when we switch to Valkyrie::ChangeSet instead of Hydra::Forms.
This object is responsible for exposing the user submitted params from a failed POST/PUT/PATCH.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#class ⇒ Object
Yes, I don’t want to delegate class to the form, but based on past experiences, there are times where SimpleForm requests class.model_name and that had better align with the underlying form.
-
#initialize(form:, input_params:, permitted_params: nil) ⇒ FailedSubmissionFormWrapper
constructor
A new instance of FailedSubmissionFormWrapper.
- #inspect ⇒ Object
- #model_name ⇒ Object
- #to_model ⇒ Object
Constructor Details
#initialize(form:, input_params:, permitted_params: nil) ⇒ FailedSubmissionFormWrapper
Returns a new instance of FailedSubmissionFormWrapper.
25 26 27 28 29 30 31 32 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 25 def initialize(form:, input_params:, permitted_params: nil) @form = form super(@form) @input_params = input_params @exposed_params = {} @permitted_params = permitted_params || __default_permitted_params__(form: form) build_exposed_params! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
69 70 71 72 73 74 75 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 69 def method_missing(method_name, *args, &block) if @exposed_params.key?(method_name) @exposed_params.fetch(method_name) else super end end |
Instance Method Details
#[](key) ⇒ Object
59 60 61 62 63 64 65 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 59 def [](key) if @exposed_params.key?(key) @exposed_params.fetch(key) else super end end |
#class ⇒ Object
Yes, I don’t want to delegate class to the form, but based on past experiences, there are times where SimpleForm requests class.model_name and that had better align with the underlying form.
Upon testing, when I don’t have this method, the Javascript for “Requirements” on the new form will not properly acknowledge that we have re-filled the HTML form with the submitted non-file fields.
43 44 45 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 43 def class @form.class end |
#inspect ⇒ Object
55 56 57 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 55 def inspect "Hyrax::Forms::FailedSubmissionFormWrapper(#{@form})" end |
#model_name ⇒ Object
47 48 49 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 47 def model_name @form.model_name end |
#to_model ⇒ Object
51 52 53 |
# File 'app/forms/hyrax/forms/failed_submission_form_wrapper.rb', line 51 def to_model self end |