Octree |
Contact Us |
Our Blog (FR)
Decidim |
Decidim Docs |
Participatory Governance (meta decidim)
Decidim Community (Matrix+Element.io)
Decidim User Fields
Add custom user fields, through configuration file and without migration. This module aims to configure in a blast new fields for subscription and profile edition. It supports:
- User registration
- User profiles
- User invitations.
⚠️ It does not support:
- Omniauth registrations
Setup the module
Add the gem to your gemfile
gem "decidim-user_fields"
Run bundle
bundle install
Create an initializer config/initializers/custom_user_fields.rb
Decidim::CustomUserFields.configure do |config|
config.add_field :birthdate, type: :date, required: true
config.add_field :province, type: :select, options: [:vd, :vs, :ar], default: :vd, required: true
config.add_field :adress, type: :textarea, required: false, rows: 10
config.add_field :purpose, type: :text, required: false
end
Available field types
:date
parameters:
required
: must choose a datemin
: date in ISO8601 where the user can not select beforemax
: date in ISO8601 where the user can not select after
:textarea
parameters:
required
: if the field is requiredmin
: minimal lengthmax
: maximal lengthrows
: how much rows the field should display
:text
parameters:
required
: if the field is required
Labels
Labels are translated, and are under the traduction scope decidim.custom_user_fields
.
Example of a fr.yml
file:
fr:
activemodel:
attributes:
user:
birthday: "Birthday"
adress: "Addresse"
purpose: "Raison d'être ici"
province: "Canton"
decidim:
custom_user_fields:
province:
options:
vd: "Vaud"
vs: "Valais"
ar: "Aarau"
Run locally
To run this module locally, we use docker-compose:
docker-compose up
This will run a decidim-user_fields
container, which sleeps.
You can run any command you want in the running container, like:
docker-compose exec -it decidim-user_fields bundle exec rails db:seed
: seed the database (run onlocalhost:3000
)docker-compose exec -it decidim-user_fields bin/webpack-dev-server
: compile assets and watch for changesdocker-compose exec -it decidim-user_fields bin/rails s -b 0.0.0.0
: run rails server in developmentdocker-compose exec -it decidim-user_fields bundle exec rspec /home/decidim/module/spec
: run tests for the moduledocker-compose exec -it decidim-user_fields bundle exec rubocop -a /home/decidim/module
: correct lint error with rubocopdocker-compose exec -it decidim-user_fields bash
: navigate your container in bash
While developping locally, you have two environments variables that can help you:
ROOT
: the root of the application using the moduleMODULE_ROOT
: the place where your gem code is.