Skip to content

Comments

Custom fields#1

Open
sergey-homenko wants to merge 2 commits intodevfrom
main
Open

Custom fields#1
sergey-homenko wants to merge 2 commits intodevfrom
main

Conversation

@sergey-homenko
Copy link
Owner

@sergey-homenko sergey-homenko commented Jan 15, 2024

Use cases:

  1. Create CustomField records:
CustomField.create!([
   { label: :name, field_type: :text_field },
   { label: :age, field_type: :number_field },
   { label: :gender, field_type: :single_select, field_value: [:male, :female, :other] },
   { label: :roles, field_type: :multiple_select, field_value: [:user, :hr, :pm, :admin] }
 ])
  1. Define custom fields for each particular model:
class User < ApplicationRecord
  include CustomFields
  
  custom_fields :name, :age, :gender, :roles
end

Custom fields feature works via CustomFields concern, which should be included in each model that needs this functionality.

Some examples from Rails console:
Screenshot 2024-01-15 at 11 04 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant