The competition form has 2 components:
- React frontend
- Rails backend
To create a competition, the frontend sends a POST request to /competitions
, which is handled by the create
method in competitions_controller.rb
. This is one of the default routes created by resources :competitions
in routes.rb
, which is why it is not explicitly defined in that file.
Adding a Field to the Competition Form
- If necessary, create and run a migration to add it to the Competition model
- Add the field(s) to cloneable/uncloneable attributes
- Add the field(s) to the dev database dumper
- Add any validations needed for these fields - strongly recommended to add tests against these validations as well
- Make the fields available in the competition form by field names to:
competition.rb#to_form_data
competition.rb#form_data_json_schema
competition.rb#form_errors
competition.rb#form_data_to_attributes
- Add the fields to the competition form by:
- Locating the relevant component in
app/webpacker/components/CompetitionForm/FormSections
- Create fields by analzying and copying/editing the existing fields
- Ensure that the necessary keys are created in en.yml (viewing the competition form where your fields have been added will tell you which keys are missing - these can take a while to update)
- Locating the relevant component in