It would e very convenient to use
if ($model->setScenario('edit')->load(Yii::$app->request->post()) && $model->validate()) {
At present the method does not return anything, so no breaking changes..
New method as:
public function setScenario($value)
{
$this->_scenario = $value;
return $this;
}
I can create PR if this suggestion is accepted..
Could be implemented. Let's wait for other opinions before submitting a new PR
It's OK to implement.
it would be nice to have some consistency on this matter. Why would we enable return $this for this setter and not for other setters. Either we choose to return $this for all setters, or not. This is a question to be answered in general.
Does not make sense for me.
Model has not been designed for chaning syntax. Such methods like load() or validate() can not return its reference,
Chaining make sense in case 3 or more methods can appear in the sequence, creating some sentence, like yii\db\Query does. Chaning of 2 methods makes program hard to read as second method can sweep the glance.
Both @dynasource and @klimov-paul are right about inconsistencies and that pretty much out weights my and @SilverFire no-objections. Won't be implemented in this case.
Most helpful comment
Does not make sense for me.
Modelhas not been designed for chaning syntax. Such methods likeload()orvalidate()can not return its reference,Chaining make sense in case 3 or more methods can appear in the sequence, creating some sentence, like
yii\db\Querydoes. Chaning of 2 methods makes program hard to read as second method can sweep the glance.