I am attaching a value obtained from the User table to an FK, however the return I have is:
protocol. fk_protocol "is not a column name and can not be used as a filter
public function actionAddProtocolo()
{
$model = new Protocolo();
if ($model->load(Yii::$app->request->post())) {
$user = Usuario::findOne([Usuario::tableName() .'.id'=> Yii::$app->user->id]);
$model->status = 0;
$model->fk_protocolador = $user->id;
$model->fk_setor_origem = $user->fk_setor;
$model->numero_processo = 'teste121';
$user_ = Protocolo::findOne([Protocolo::tableName() . '. fk_protocolador'=> $model->fkProtocolador])->where('YEAR('. $model->data_abertura.')')->orderby('YEAR('. $model->data_abertura.')');
$model->save(false);
}
}
The error happens in this fk_protocol
In the model, FK is defined as:
[['fk_protocolador'], 'integer'],
[['fk_protocolador'], 'exist', 'skipOnError' => true, 'targetClass' => Usuario::className(), 'targetAttribute' => ['fk_protocolador' => 'id']],