0

I have a matrix called 'Election' with the structure:

Block: role
 - Text field: roleName
 - Table field: candidates
 -- Text field: fullName
 -- Number field: votes

My module can edit the roleName text field with:

//get role
$role = Craft::$app->getMatrix('election')->getBlockById($roleId);

//set roleName field
$role->setFieldValue('roleName', 'President');

I know which row of the table I want to edit, but I cannot work out how to edit the fields in the table? I am specifically trying to increase the 'votes' in the Number field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.