[TYPO3-project-formidable] how to combine _two_ form-fields to be inserted/updated as a _single_ db-field

Michael Wilde michael.wilde at yahoo.de
Mon Jan 29 18:31:53 CET 2007


Ad 2nd Question:
================

it would be useful if "adodb_mktime" could be used instead of "mktime" 
in future releases of Formidable. I had to create a user defined 
renderlet and replace

$tstamp = mktime($hour, $minute, $second, $month, $day , $year);

with:

$adodb = t3lib_div::makeInstance('tx_..._adodb_time');
$tstamp = $adodb->adodb_mktime($hour,$minute,$second,$month,$day,$year);

within the function "__date2tstamp()" of "class.tx_rdtdate.php". It 
works fine now.


Michael Wilde schrieb:
> Hi there,
> 
> 1st Question:
> =============
> 
> within my application I would like to read the values of one date _and_ 
> one time form-field and store it together as a _single_ timestamp in a 
> database. And vice versa it should be possible to read a _single_ 
> timestamp and display it as two seperate form fields again.
> -----------------------------------------------------------------------
> 
> The table looks as follows:
> 
> uid | pid | ... | my_timestamp
> ----+-----+ ... +-------------
> 1   | 2   | ... | 1169485200
> 
> within my form.xml file I've got two form-fields "my_date" and 
> "my_time". "my_date" is a DATE renderlet and "my_time" is a TEXT 
> renderlet. Both form-fields should be combined to a single timestamp to 
> be inserted into the database (--> "my_timestamp").
> 
> To do so I've used beforeinsertion and beforerender processes in the 
> form.xml datahandler:
> 
> <process>
>   <beforeinsertion>
>     <userobj>
>       <php><![CDATA[               
>         $oThis = t3lib_div::makeInstance("tx_myapp_pi1");
>         $aData = array_pop(func_get_args());
>         return $oThis->beforeInsertationOfBirthday($aData);
>       ]]></php>
>     </userobj>
>   </beforeinsertion>       
>   <beforerender>
>     <userobj>
>       <php><![CDATA[               
>         $oThis = t3lib_div::makeInstance("tx_myapp_pi1");
>         $aData = array_pop(func_get_args());
>         return $oThis->beforeRenderOfBirthday($aData);
>       ]]></php>
>     </userobj>
>   </beforerender>   
> </process>
> 
> The content of the two user-functions:
> 
> function beforeInsertationOfBirthday($aData) {
>   $aData['my_timestamp'] =
>       $this->convertToTimestamp($aData['my_date'],$aData['my_time']);
>   return $aData;
> }
> 
> function beforeRenderOfBirthday($aData) {
>   $aData['my_date'] = $this->convertToDate($aData['my_timestamp']);
>   $aData['my_time'] = $this->convertToTime($aData['my_timestamp']);
>   return $aData;
> }
> 
> The problem here is that a valid timestamp is correctly read out of the 
> database and it is correctly rendered, but it is not possible to insert 
> a timestamp into the database. The value for "my_date" and "my_time" in 
> the variable $aData of beforeInsertationOfBirthday() seem to be not 
> available.
> 
> Everything works fine as long as the name of the form-fields are the 
> same as the names of the table-columns in the database. But I can't 
> figure out how to use fieldnames that do not exist in the database.
> 
> This means: everything works fine for a field with the name "my_date2" 
> and a table-column with the name "my_date2". Here the data is inserted 
> correctly. But it is not possible for me to change the field name to 
> e.g. "my_date3". Further it is not possible to use a second field 
> "my_time2", combine it with "my_date2" and insert the resulting 
> timestamp as "my_timestamp" into the database.
> 
> Hope anyone that understood the problem can help me further on this.
> 
> 
> 2st Question:
> =============
> 
> Is there any possibility to store dates before 1970 as timestamp into a 
> database using Formidable?
> 
> TIA,
> Michael.


More information about the TYPO3-project-formidable mailing list