Skip to content

Commit

Permalink
docs: hasMany field docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mle-moni committed Aug 14, 2024
1 parent 8c8b781 commit 415837d
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions docs/src/content/docs/reference/views/models/has_many.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: HasMany field
sidebar:
order: 1011
description: Adomin HasMany field reference
---

In the table page, a HasMany field will look like this

![field image](~/assets/images/reference/models/has_many/table_has_many.png)

In the create / edit page

![edit field image](~/assets/images/reference/models/has_many/has_many.png)

## Config

### modelName

Name of the model referenced by this field

e.g. if you have a User that hasMany Idea, the value should be 'Idea'

### labelFields

Fields in the referenced model to use for label

e.g. `['title']`

### labelFieldsSeparator

Separator between label fields, defaults to ', '

### fkName

Name of the foreign key for the referenced model, if not provided we try to guess it.

If you have User that hasMany Idea, the default value will be 'userId'

### fkType

Can be either 'string' or 'number', represents the type of the foreign key, defaults to 'number'

### localKeyName

Name of the local key in the referenced model

e.g. if you have User that hasMany Idea, the value should be the primary key of the Idea model

Default to 'id'

### localKeyType

Can be either 'string' or 'number', represents the type of the local key, defaults to 'number'

### preload

If true, adomin will preload the relation, defaults to true

Setting to false can be usefull if you need to customize the query with `queryBuilderCallback`

### allowGlobalFilterSearch

If true, adomin will allow to search in the related models through the global filter

Default to false

### allowRemove

If true, adomin will allow to set the relation to null, defaults to false

e.g. if you have User that hasMany Idea, with allowRemove = true, you allow to set Idea.userId to null
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/views/models/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ virtualColumns: [

### [BelongsTo field](/adomin/reference/views/models/belongs_to/)

### HasMany field
### [HasMany field](/adomin/reference/views/models/has_many/)

### HasOne field

Expand Down

0 comments on commit 415837d

Please sign in to comment.