I use TYPO3 7.6 and extbase. I have model "Ticket", "Answer" and "Status"
Ticket n:1 -> Status;
Ticket 1:n -> Answer;
Answer n:1 -> Ticket;
Status 1:n -> Ticket;
In Answer Controller
public function createAction(\Vendor\Extname\Domain\Model\Ticket $ticket, \Vendor\Extname\Domain\Model\Answer $newAnswer)
{
//Set tikcet and it's normaly
$newAnswer->setTicket($ticket);
// Try to set status and get error
$newAnswer->getTicket($ticket)->setStatus($status);
}
In template Answer/New
<f:form action="create" method="POST" enctype="multipart/form-data" name="newAnswer" controller="Answer" object="{newAnswer}"
arguments="{ticket:ticket}">
<f:form.select class="form-control" property="ticket.status" name="status" options="{status}"
optionLabelField="title"
optionValueField="uid" />
</f:form>
and I get
"PHP Catchable Fatal Error: Argument 1 passed to Domain\Model\Ticket::setStatus() must be an instance of Domain\Model\Status, null given"
How can I set value for multiple model objects via one form? Set status for ticket when I create answer.