Module: Decidim::FormFactory
- Extended by:
- ActiveSupport::Concern
- Included in:
- Accountability::ResultsCsvImporter, Admin::ApplicationController, AmendmentsController, Debates::DebatesController, Devise::OmniauthRegistrationsController, Devise::RegistrationsController, EditorImagesController, FollowsController, GroupEmailConfirmationsController, GroupInvitesController, GroupMembersController, GroupsController, Initiatives::CreateInitiativeController, Initiatives::InitiativeSignaturesController, Initiatives::InitiativeVotesController, Initiatives::InitiativesController, Meetings::MeetingClosesController, Meetings::MeetingsController, Meetings::Polls::AnswersController, Messaging::ConversationsController, NewslettersOptInController, Proposals::CollaborativeDraftsController, Proposals::ProposalsController, ReportUsersController, ReportsController, SearchesController, System::ApplicationController, UploadValidationsController, UserConversationCell, UserConversationsController, UserGroupJoinRequestsController, UserProfile
- Defined in:
- decidim-core/app/controllers/concerns/decidim/form_factory.rb
Overview
A factory to build forms. This is done to add a context when possible, so that forms can act based on data that varies between requests. This is mostly done so that i18n form fields can be properly validated with the ‘current_organization` available locales, instead of doing so against all the available locales in the platform. The `current_organization` varies between requests, so the form need some way to access this data.
Examples:
# in a controller, mostly in a `create` action:
form(MyFormClass).form_params(params)
# in a controller, mostly in a `new` action:
form(MyFormClass).instance
# in a controller, mostly in an `edit` action:
form(MyFormClass).form_model(@my_resource)