modmore / ClientConfig

ClientConfig is a MODX Revolution Extra to allow clients to maintain settings in a user friendly way.
https://docs.modmore.com/en/Open_Source/ClientConfig/index.html
MIT License
28 stars 27 forks source link

Accessing setting via FormIt hook always yields empty value #186

Open sonicpunk opened 3 years ago

sonicpunk commented 3 years ago

Summary

Trying to access a setting field using $modx->getOption() always returns an empty string.

Step to reproduce

Inside of a hook snippet try to call up a ClientConfig setting

Observed behavior

It returns empty

Expected behavior

It should return the saved value

Environment

ClientConfig version 2.3.0-pl, FormIt version 4.2.5-pl, MODX version 2.7.2-advanced, Operating System Apache, MySQL 5.6 version, PHP version 7.3

Mark-H commented 3 years ago

Definitely checked for typos in the key name? And it does work if you place the same snippet just on the page instead of as a hook?

sonicpunk commented 3 years ago

Hey Mark, I tested it as just a snippet and it also returns no value. I checked the name of the key a million times. If I call it using placeholder, it does render the value.

[[++webinar_confirmation_email_text_en]]

$emailText = $modx->getOption('webinar_confirmation_email_text_en', null, '');

Swapping out the key name with a standard modx system setting returns a value.

sonicpunk commented 3 years ago

If I add the key as a placeholder in the template, then the snippet call on the same page also gets the value and outputs it to the modx log. Something weird going on,

Mark-H commented 3 years ago

That sure does sound weird. Is this a global setting or a context-specific one that may be affected by #109?

sonicpunk commented 3 years ago

Event a simple snippet placed in the template like this returns nothing:

$emailText = $modx->getOption('webinar_confirmation_text_en', null, '', true); return $emailText;

but the placeholder does: [[++webinar_confirmation_text_en]]

Both MODX events are activated on the plugin. The setting is a global setting. We are using language contexts.

Mark-H commented 3 years ago

If you can email a login to support@modmore.com, with a link to this issue, I'd like to do some debugging to see what might be going on there. Should have some spare time near the end of the week to take a look.

sebastian-marinescu commented 2 years ago

I'm not sure if it's related, but in my case on the Contact-Form the "contact-mail" setting, which is also a ClientConfig-setting wouldn't work, unless I called it un-cached:

&emailTo=`[[!++contact_mail]]`

Just leaving it here for future problem-solvers.