raoul2000 / yii2-workflow

A simple workflow engine for Yii2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unsafe attributes

Faryshta opened this issue · comments

How can I declare an attribute as unsafe? That means it can be massively assigned using the Model::load() method.

Regulary if I want the 'paymet_method' to only be asigned during 'select-payment'. The code looks like this.

public function rules()
{
    return [['!payment_method'], 'safe', 'except' => 'select-payment'];
}

Unfortunately workflow makes its own behaviors and they won't work during the load() execution

public function rules()
{
    return [['!payment_method'], 'safe', 'except' => WorkflowScenario::enterStatus('select-method')];
}

This one won't work since the scenario only exists during transitions, not during loading.

commented

Hi,
you are right, massive assignements and safe/unsafe rule is not handled by the dynamic workflow scenario which has only been designed to handle attribute validations. Transition driven Validation is triggered by the BEFORE_VALIDATE event but as there is no such thing for assignement, I don't see how it could be implemented.
I hope you'll be able to find a workaround ...

ciao

thats a helpful response. i will have to figure something for that.