Default for Many to Many Relationship Using the Relation Controller
0
When using a many to many relation using the relation controller you can set a default value like so—illustrated using a many to many relation ship to users
:
Controller
public function formExtendFields($form)
{
if ($this->formGetContext() === 'create') {
$model = $this->formCreateModelObject();
$sessionKey = $this->formGetSessionKey()`
$currentUser = BackendAuth::getUser();
$model->users()->add($currentUser, $sessionKey);
}
}
There are no comments yet
Be the first one to comment