Jump to content

Make setting field settings in context of templates less verbose via API


owzim
 Share

Recommended Posts

Currently to change the 'summary' description in context of 'basic-page' we would have to do this:

// 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 = "'basic-page' summary description";

// save new setting in context
$fields->saveFieldgroupContext($f, $t->fieldgroup);

What I'd like is something like this

// get the field
$f = $fields->get('summary');

// value of the field
$f->set('description', "'basic-page' summary description", $context = 'basic-page');

// save new setting, perhaps optional, because behind
// the scenes `saveFieldgroupContext` has been called already?
$f->save();

Similar for getting in context:

$f->get('description', $context = 'basic-page');

Not only is it more intuitive, but less verbose, in my opinion.

What do you think?

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...