Jump to content

Change field description in context via API


Recommended Posts

I've really tried my best but seems like I'm not able to change a fields description text in context of a template via the api.

$template->fieldgroup->title->description = "This should be the description";

Anybody having the same problem?

Note: if that works I also want to change the description in different languages, but that should not be a problem.

Link to comment
Share on other sites

Something like this should work...

$t = $templates->get('basic-page');//get the template
$f = $t->fieldgroup->getField('summary', true);//get the field in context of this template
$f->description = "This should be the description";//value of the field
$fields->saveFieldgroupContext($f, $t->fieldgroup);//save new setting in context

Edited for clarity...
In this example, we are changing the description of the field 'summary' in the context of the template 'basic-page'.

Edited by kongondo
  • Like 10
Link to comment
Share on other sites

  • 3 weeks later...
  • 4 months later...

I just had to fiddle around with that.

It might be important to note that if you apply ANY field setting via $fields->saveFieldgroupContext all other field settings are copied over to the contextual settings as well.

So if you only set columnWidth the title (and all others) is copied over too. If you change the original non-contextual title, the old title stays in the fieldgroup context.

I wish the behavior would be like merging values, so when I change columnWidth only, all other values are taken on the fly from the non-contextual field settings when requested.

Link to comment
Share on other sites

  • 1 year later...

the solution provided here did not work for me! i'm using pw 3.0.36 and this worked and is even easier :)

$fg = new Fieldgroup();
$fg->name = 'rocksvns';

// set version field visible for this template
$fg->setFieldContextArray($this->fields->get('rocksvn_version')->id, array(
    'collapsed' => 0,

$t = new Template();
$t->name = 'rocksvns';
$t->fieldgroup = $fg;

tracy helped a lot here again :)

2016-10-24 13_39_28-Edit Template_ rocksvns • sandbox.dev.png

  • Like 4
Link to comment
Share on other sites

  • 1 year later...

Stupid question: is it possible to include markup in a field description?

I'd like to add a simple modal link as cross-reference (sort of a cheatsheet). Tried it via API as well, but no dice.

<p class="description">
	<a href="foo/client-list/" class="pw-modal pw-modal-large ui-corner-all">Open client list</a>

Any other methods? A hook?

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...