JamesBarnsley
(Jamesbarnsleyfreelance)
February 2, 2015, 4:01pm
1
I have defined a relation as follows …
public function getMilestone() {
return $this->hasOne(Milestone::className(), ["id" => "fkIDWithMilestoneID"]);
}
When I use "Milestone.name" in a datagrid it states …
Relation names are case sensitive. app\models\Task has a relation named "milestone" instead of "Milestone".
Which is fine because I just use "milestone.name" and it works.
However I am just curious where has got the lowercase "milestone" from?
evercode
(Ikon321)
February 2, 2015, 7:12pm
3
When using magic get method, where get is not explicitly part of the method call, the first word of the method is lower case. So getMilestone, would become $this->milestone, for example. Not sure if this applies to your use case, but it is likely the cause.
JamesBarnsley
(Jamesbarnsleyfreelance)
February 2, 2015, 7:33pm
4
Ok thanks guys.
Whenever I have done magic properties before it was always uppercase so getMilestone would have been $obj->Milestone etc.
But what you are saying seems to be the case, but in the past I always had to call $obj->Milestone to call the magic property, very strange.