We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Passing NULL to a related alias do not update the model

I have a Project-model with the following relation to an assigned account:

$this->belongsTo("assigned_account_id", "MyNamespace\Account", "id", array("foreignKey" => array("allowNulls" => true), "reusable"=>true, 'alias' => 'assigned_account'));

When I save the model with $this->assigned_account = null; the database does not update and I get no errors (the previous value is still saved). It works as expected when I set $this->assigned_account = $my_related_model;.

If I save the model with $this->assigned_account_id = null; the database is updated as expected. Why can I not set the related alias to null? Is this expected behavior?

Hi @Marius do you try with action param in foreignKeys?? info

Good luck