I'm just trying to set up a relation in OctoberCMS backend where a child form should get a value from the parent form as a suggestion (default).
In detail there are two models linked by a belongsTo relation (an attendee belongs to a tournament) 1st the parent model (field.yaml) covering a sports tournament:
tournament:
# ... some other fields
start_date:
label: Start date
type: date
attendees:
label: Attendees
type: partial
2nd the child model for the attendees:
attendee:
name:
label: Name
type: text
start_date:
label: Start date
type: date
# how to get the value from tournament->start_date as preset?
A parent form (on a sports tournament) has a start date as well as a related partial covering athletes attending the game. Each athlete also has an individual start date field which I would like to prefill with the start date of the game as soon this form is called by the parent tournament form. But it has to be editable, because not all attendees will start at the same day.
There is a built in function to preset a filed with a value from another field of the same form, but unfortunately I cannot find a solution how to get the value from a parent form.
Thanks in advance!
You can add
relationExtendManageWidget
method into yourTournament controller
and extend its behavior. you can nowinject initial values for your new modal
while creating new records.if any doubt please comment.