Field/template context
Problem
Fields can have template-contextual settings and as of ProcessWire 2.5.7 you can set all field settings in a template context. Using the API it works a bit differently than the usual $f->set('setting', $value); $f->save();
.
Solution
// get the template
$t = $templates->get('basic-page');
// get the field in context of this template
$f = $t->fieldgroup->getField('summary', $useFieldgroupContext = true);
// value of the field
$f->description = "Description of 'summary' only in context of 'basic-page'";
// save new setting in context
$fields->saveFieldgroupContext($f, $t->fieldgroup);
Resources
Version: 1.0.0
Added: 2015-01-17
Authors: owzim, kongondo