This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

christian15093
christian15093

Hello,

I am trying to figure out if this is the best way to do this. I have a model Judge with id and name for the fields right now and a model Show with id, name and judges for the fields. In my backend form for Show, I have a repeater for the judges and a relation with a dropdown.


judges:
    label: 'Judges'
    prompt: 'Add a judge'
    type: repeater
    form:
        fields:
            judge_id:
                label: 'Name'
                nameFrom: name
                type: relation

Here is the part of the code for model Show


public $jsonable = ['judges'];

public $belongsTo = [
  'judge_id' => ['namespace\Models\Judge', 'order' => 'name'
];

This is working fine, but I can't get the shows with judges info in one database query since the judges field will contain the id in an array. I can get the judges info by running another query and append the info to the result.

I'm going to try switching the judges to belongsToMany relation but the backend form will render it as checkboxes instead of drop down, which isn't ideal. I haven't looked at a way to change the renderer to be a drop down instead of checkboxes yet, but I'm just wondering if this would be a good approach.

Thank you.

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.