diff --git a/app/forms/hyrax/forms/workflow_responsibility_form_decorator.rb b/app/forms/hyrax/forms/workflow_responsibility_form_decorator.rb index 10fc33a32..87119cdba 100644 --- a/app/forms/hyrax/forms/workflow_responsibility_form_decorator.rb +++ b/app/forms/hyrax/forms/workflow_responsibility_form_decorator.rb @@ -5,13 +5,21 @@ module Hyrax module Forms module WorkflowResponsibilityFormDecorator + ## + # @note We introduced this little crease in the code to allow for conditional switching; and + # thus avoid copying a very large controller + # (e.g. Hyrax::Admin::WorkflowRolesController) + # @see Hyrax::Forms::WorkflowResponsibilityGroupForm module ClassMethods - # Determine which form it is, user or group + ## + # Determine which form it is, user or group. By default, it will be a user + # (e.g. {Hyrax::Forms::WorkflowResponsibilityForm}); however when you provide a :group_id it + # will be a group form (e.g. {Hyrax::Forms::WorkflowResponsibilityGroupForm}. def new(params = {}) - if params[:user_id].present? - super - else + if params[:group_id].present? Forms::WorkflowResponsibilityGroupForm.new(params) + else + super end end end diff --git a/app/forms/hyrax/forms/workflow_responsibility_group_form.rb b/app/forms/hyrax/forms/workflow_responsibility_group_form.rb index 71f4323fb..7cb6d0715 100644 --- a/app/forms/hyrax/forms/workflow_responsibility_group_form.rb +++ b/app/forms/hyrax/forms/workflow_responsibility_group_form.rb @@ -10,6 +10,11 @@ def initialize(params = {}) model_instance.agent = group.to_sipity_agent end + ## + # This method is necessary for the HTML form fields to have the correct name (e.g. ``). + # + # @see ActiveModel::Naming def model_instance @model ||= Sipity::WorkflowResponsibility.new end