MODX FormIt overriding POST values

319 views Asked by At

I am trying to modify posted phone number using custom hook, but for some reason the value isn't changed. Here is my hook:

require '/components/vendor/autoload.php';
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();

$phone = $hook->getValue('Phone');
$country = $hook->getValue('Country');

$numberProto = $phoneUtil->parse($phone, $country);

$formated = $numberProto->getNationalNumber();
$code = $numberProto->getCountryCode();

$formatedPhone = '+'.$code.$formated;

$hook->setValue('Phone', $formatedPhone);
return true;

So, I am just taking the Phone field, populate it with the code and set value back. As I can see, everything works fine (by dumping data) up until $hook->setValue('Phone', $formatedPhone);

What's the problem here?

1

There are 1 answers

0
Benjamin Dean On BEST ANSWER

So, everything was fine actually. I was looking at the Post Data via network tab, but the real posted data was completely fine.