I have a Matrix field named "skillLevels" with a single block type. Each row has 2 fields, "skillName" and "skillLevel"
skillName is a relationship to another entry (Skills) skillLevel is a simple integer.
I am building a custom plugin which takes post data from a form. The form contains an entry ID ($groupId), a skill name and a value to use to modify the level of that skill.
$groupEntry = craft()->entries->getEntryById($groupId);
$skillLevels = $groupEntry->skillLevels;
foreach($skillLevels as $skill){
$skillLevel = $skill->skillLevel; // outputs the skill level
$skillName = $skill->skillName; // this doesn't work
}
$skill->$skillLevel
gives me the integer stored in that field.
But $skill->skillLevel
does not gives me a model. I then tried using $skill->skillLevel->id but still no luck.
How can I look through the Matrix rows to find the row that matches the skill name coming from the form Post data?