I’m trying to set data within a global set. I’ve tried the following without success:

$globalSetHandle = 'settings';
$globalSet = craft()->globals->getSetByHandle($globalSetHandle);

$globalSet->fieldHandle = 'value';

craft()->globals->saveContent(GlobalSetModel $globalSet);

2 Answers 2


Try using setContentFromPost, as mentioned in this answer from Brandon.

$content = array(
    'fieldHandle' => 'value',


You can also use a front-end form:

<form method="post">
  {{ getCsrfInput() }}
  <input type="hidden" name="action" value="globals/saveContent">
  <input type="hidden" name="setId" value="123"> 
  <input type="text" name="fields[fieldname]" value="{{globalsetslug.fieldname}}">
  <input type="text" name="fields[anotherfieldname]" value="{{globalsetslug.anotherfieldname}}">
  <input type="submit" value="Save globals" />

Of course you need to replace 123 by your globals set id and globalsetslug by your globals set slug. You are not required to include all globals set fields in your form, Craft will save only those inside the form.

I know it's an old post, but perhaps this will help others!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.