The abbreviation FK refers to Foreign Key in GreenLight, just like in any database-related topic. An FK input handles 1:1 relationships with simple drop-down select inputs.
The 1:1 relationships handled by the FK input type have to be set up properly according to the Laravel specs. GreenLight uses Reliese to generate models, which means, most likely these relationships are already going to be implemented in your models.
Parameter name | Description |
---|---|
model | Class name of the model connected to the current one |
There are known issues to consider while using FK Inputs:
These problems are expected to be fixed in a further release of GreenLight.
Let's say you need a system that you can build a blog with. If you have no special needs, you might want to use the article system GreenLight supports. The Article model has two 1:1 relationships, but let's ignore the user_id field as we only want to handle the category of an article in an admin page.
GreenLight's Article model has the following FK field configured in vendor/greenroom/greenlight/src/Resources/forms/article.yaml to handle the relationship between Article and ArticleCategory:
article_category_id:
type: fk
name: Kategória
parameters: { model: ArticleCategory }