XF 2.1 Access value of addon's another option inside validation callback?

asprin

Active member
Hi experts,

I've the following validation class defined in one of the addon options
1673487879322.png

And inside this function, I'm attempting to get the value of another optionId
1673487925128.png

So is possible to get what its value is in the aforementioned callback function?

PHP:
public static function checkFoo(&$value, \XF\Entity\Option $option, $optionId)
{     
    /*
    if(genMulFirst == 'somevalue')
    {
        then go ahead and perform some validation for $value
    }
    */
    
    return true;
}
 
Solution
Kinda boring question :)

PHP:
if (\XF::options()->genMulFirst === 'somevalue')

You could run into problems though if both options are on the same page.
Kinda boring question :)

PHP:
if (\XF::options()->genMulFirst === 'somevalue')

You could run into problems though if both options are on the same page.
 
Solution
Sorry, didn't get this. On the same page as in?
On the same options page.

For example options boardActive and boardInactiveMessage on the same page while boardTitle is on a different page.

Why does that matter?

If both are on the same page the validation code might check the existing option value, not the (possibly) updated value as \XF::options() might not yet have been updated when the valudation code is executed.
 
Back
Top Bottom