Skip to content

Commit

Permalink
Merge branch 'main' of github.com:avo-hq/avodocs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Apr 18, 2024
2 parents d9cb43c + e3b50bb commit 8a37c99
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/3.0/associations/has_and_belongs_to_many.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Similar to [`belongs_to`](./belongs_to#searchable-belongs-to), the `has_many` as
<!-- @include: ./../common/scopes_common.md-->
<!-- @include: ./../common/show_hide_buttons_common.md-->
<!-- @include: ./../common/reloadable.md-->
<!-- @include: ./../common/association.md-->
1 change: 1 addition & 0 deletions docs/3.0/associations/has_many.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ field :members,
<!-- @include: ./../common/scopes_common.md-->
<!-- @include: ./../common/show_hide_buttons_common.md-->
<!-- @include: ./../common/reloadable.md-->
<!-- @include: ./../common/association.md-->
16 changes: 16 additions & 0 deletions docs/3.0/common/association.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:::option `association`

<VersionReq version="3.6.2" />

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 }
```
21 changes: 20 additions & 1 deletion docs/3.0/field-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<VersionReq version="3.6.2" />

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"
```
:::

0 comments on commit 8a37c99

Please sign in to comment.