You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
First, I'm on a Contao 4.9, Isotope 2.6, PHP 7.4. I looked for this error in other issues, but did not find something similar. Also, I do not understand German so sorry if it was mentioned in a German issue :)
I put a save_callback on the postal field inside the tl_iso_address DCA (to compute with more precise rules for my customer). The AddressBook module triggers them, since it goes through the Form class from Haste package.
But for the address checkout step, it is ignored.
I did an override of the function validateFields inside vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/CheckoutStep/Address.php class, so now it works for me, but maybe I missed something, or it is something you want to put in the core.
My function replacement below.
Thanks for your time and for the work you put in Isotope :)
protectedfunctionvalidateFields($blnValidate)
{
$arrAddress = array();
$arrWidgets = $this->getWidgets();
foreach ($arrWidgetsas$strName => $objWidget) {
// Validate inputif ($blnValidate) {
$objWidget->validate();
$varValue = (string) $objWidget->value;
// Convert date formats into timestampsif ('' !== $varValue && \in_array($objWidget->dca_config['eval']['rgxp'], array('date', 'time', 'datim'), true)) {
try {
$objDate = new \Date($varValue, $GLOBALS['TL_CONFIG'][$objWidget->dca_config['eval']['rgxp'] . 'Format']);
$varValue = $objDate->tstamp;
} catch (\OutOfBoundsException$e) {
$objWidget->addError(
sprintf(
$GLOBALS['TL_LANG']['ERR'][$objWidget->dca_config['eval']['rgxp']],
$GLOBALS['TL_CONFIG'][$objWidget->dca_config['eval']['rgxp'] . 'Format']
)
);
}
}
// Wrap in a try catch since Contao use Exception to catch backend errorstry {
if (is_array($objWidget->dca_config['save_callback'] ?? null)) {
foreach ($objWidget->dca_config['save_callback'] as$callback) {
if (is_array($callback)) {
$varValue = \System::importStatic($callback[0])->{$callback[1]}($varValue, $dc);
} elseif (is_callable($callback)) {
$varValue = $callback($varValue, $dc);
}
}
}
} catch (\Exception$e) {
$objWidget->addError($e->getMessage());
}
// Do not submit if there are errorsif ($objWidget->hasErrors()) {
$this->blnError = true;
} // Store current valueelseif ($objWidget->submitInput()) {
$arrAddress[$strName] = $varValue;
}
} else {
\Input::setPost($objWidget->name, $objWidget->value);
$objValidator = clone $objWidget;
$objValidator->validate();
if ($objValidator->hasErrors()) {
$this->blnError = true;
}
}
}
return$arrAddress;
}
The text was updated successfully, but these errors were encountered:
Thanks for your bug report and providing a solution. I think that's very valid and should be added to the next minor release. I'll look into the details as soon as I'm preparing version 2.9.
Hi there,
First, I'm on a Contao 4.9, Isotope 2.6, PHP 7.4. I looked for this error in other issues, but did not find something similar. Also, I do not understand German so sorry if it was mentioned in a German issue :)
I put a
save_callback
on thepostal
field inside thetl_iso_address
DCA (to compute with more precise rules for my customer). TheAddressBook
module triggers them, since it goes through theForm
class from Haste package.But for the address checkout step, it is ignored.
I did an override of the function
validateFields
insidevendor/isotope/isotope-core/system/modules/isotope/library/Isotope/CheckoutStep/Address.php
class, so now it works for me, but maybe I missed something, or it is something you want to put in the core.My function replacement below.
Thanks for your time and for the work you put in Isotope :)
The text was updated successfully, but these errors were encountered: