MichaMichaMicha Posted June 12, 2014 Share Posted June 12, 2014 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"; $template->fieldgroup->title->save(); $template->fieldgroup->save(); 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 More sharing options...
kongondo Posted June 12, 2014 Share Posted June 12, 2014 (edited) 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 June 12, 2014 by kongondo 10 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted June 12, 2014 Share Posted June 12, 2014 +1 like 1 Link to comment Share on other sites More sharing options...
MichaMichaMicha Posted June 13, 2014 Author Share Posted June 13, 2014 Thanks. Have not had the time to check it, but it already looks good! Edit: Ryan quickly fixing things? https://github.com/ryancramerdesign/ProcessWire/commit/705de9e44ca76c03b1a1b0f5d39f7ef6b665cba8 1 Link to comment Share on other sites More sharing options...
MichaMichaMicha Posted June 30, 2014 Author Share Posted June 30, 2014 Works, and the following code should set the label in different languages (in combination with the code kongondo posted). $english = $languages->get("english")->id; $f->set("label{$english}","Date"); 2 Link to comment Share on other sites More sharing options...
owzim Posted October 30, 2014 Share Posted October 30, 2014 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 More sharing options...
bernhard Posted October 24, 2016 Share Posted October 24, 2016 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'; $fg->add($this->fields->get('title')); $fg->add($this->fields->get('rocksvn_version')); $fg->save(); // set version field visible for this template $fg->setFieldContextArray($this->fields->get('rocksvn_version')->id, array( 'collapsed' => 0, )); $fg->saveContext(); $t = new Template(); $t->name = 'rocksvns'; $t->fieldgroup = $fg; $t->save(); tracy helped a lot here again 4 Link to comment Share on other sites More sharing options...
dragan Posted January 23, 2018 Share Posted January 23, 2018 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> </p> Any other methods? A hook? Link to comment Share on other sites More sharing options...
bernhard Posted January 23, 2018 Share Posted January 23, 2018 see this example: the key is the entityEncodeText option: https://processwire.com/api/ref/inputfield/ 3 Link to comment Share on other sites More sharing options...
adrian Posted January 23, 2018 Share Posted January 23, 2018 I addition to the entityEncodeText that @bernhard mentioned, you might also find this useful: http://modules.processwire.com/modules/dynamic-description-notes/ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now