This is a very frustrating problem.
I have a save_callback on a field for a new rgxp called "month" this accpets and checks that the $varValue is in the format:
01/1957
if not it generates a format error. if the format is ok, then I create a date from that format using the $varValue, e.g.
$objDate = new Date($varValue, $GLOBALS['TL_CONFIG']['monthFormat']); // this is a new format also added to Settings
Then it returns the tstamp to the savecallback.
However, I added a global $counter variable and incremented it, and this save_callback function is called twice. Now it works 100% in the first call, but of course now in the second call, it is called with the $varValue which is a timestamp, and of course that fails all the checking routines (as it's no longer in the format "01/1957" or "m/Y").
I've done a backtrace and this is the callstack:
global counter == 1;
#0 YearMonth->saveYearMonth(01/1957, DC_ProductData Object ()) called at [/www/htdocs/w00fcf0a/system/drivers/DC_Table.php:2656]
#1 DC_Table->save(01/1957) called at [/www/htdocs/w00fcf0a/system/modules/backend/DataContainer.php:329]
#2 DataContainer->row() called at [/www/htdocs/w00fcf0a/system/drivers/DC_ProductData.php:681]
#3 DC_ProductData->edit() called at [/www/htdocs/w00fcf0a/system/modules/backend/Backend.php:287]
#4 Backend->getBackendModule(iso_products) called at [/www/htdocs/w00fcf0a/contao/main.php:120]
#5 Main->run() called at [/www/htdocs/w00fcf0a/contao/main.php:230]
global counter == 2;
#0 YearMonth->saveYearMonth(-410230800, DC_ProductData Object ()) called at [/www/htdocs/w00fcf0a/system/drivers/DC_Table.php:2656]
#1 DC_Table->save(01/1957) called at [/www/htdocs/w00fcf0a/system/modules/backend/DataContainer.php:329]
#2 DataContainer->row() called at [/www/htdocs/w00fcf0a/system/drivers/DC_ProductData.php:681]
#3 DC_ProductData->edit() called at [/www/htdocs/w00fcf0a/system/modules/backend/Backend.php:287]
#4 Backend->getBackendModule(iso_products) called at [/www/htdocs/w00fcf0a/contao/main.php:120]
#5 Main->run() called at [/www/htdocs/w00fcf0a/contao/main.php:230]
Why would the same routine be called twice upon save? That defeats the purpose of the save_callback (to format the data correctly).
Bookmarks