diff --git a/docs/3.0/associations/has_and_belongs_to_many.md b/docs/3.0/associations/has_and_belongs_to_many.md index 8d7b8e3d..7ebec94e 100644 --- a/docs/3.0/associations/has_and_belongs_to_many.md +++ b/docs/3.0/associations/has_and_belongs_to_many.md @@ -37,3 +37,4 @@ Similar to [`belongs_to`](./belongs_to#searchable-belongs-to), the `has_many` as + diff --git a/docs/3.0/associations/has_many.md b/docs/3.0/associations/has_many.md index 94e25a0c..b55c13d3 100644 --- a/docs/3.0/associations/has_many.md +++ b/docs/3.0/associations/has_many.md @@ -39,3 +39,4 @@ field :members, + diff --git a/docs/3.0/common/association.md b/docs/3.0/common/association.md new file mode 100644 index 00000000..df6717e3 --- /dev/null +++ b/docs/3.0/common/association.md @@ -0,0 +1,16 @@ +:::option `association` + + + +The `for_attribute` option allows to specify the association used for a certain field. This option make possible to define same association with different scopes and different name several times on the same resource. + +#### Usage +```ruby-vue +field :reviews, + as: :{{ $frontmatter.field_type }} + +field :special_reviews, + as: :{{ $frontmatter.field_type }}, + for_attribute: :reviews, + scope: -> { query.special_reviews } +``` diff --git a/docs/3.0/field-options.md b/docs/3.0/field-options.md index 88595b5f..a6135ec6 100644 --- a/docs/3.0/field-options.md +++ b/docs/3.0/field-options.md @@ -643,6 +643,25 @@ field :name, as: :text, html: { field :status, as: :select, summarizable: true # or field :status, as: :badge, summarizable: true +``` +This section is WIP. ::: -This section is WIP. +:::option `for_attribute` + + +Allows to specify the target attribute on the model for each field. By default the target attribute is the field's id. + +Usage example: + +```ruby{6} + field :name, + as: :text + + field :secondary_field_for_name, + as: :text, + for_attribute: :name, + only_on: :edit, + help: "Secondary field for name using for_attribute option" +``` +:::