[TYPO3-templavoila] fce: default value for input field - problems...

Peter Klein pmk at io.dk
Thu Oct 8 20:12:28 CEST 2009


Hi Stig.

You can render the field as type="user". Then you have full control over how 
it looks and what it contains..
http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.2.0/view/4/2/#id4302851

Example:

FlexForm setup:
-- cut --
   <userfunc_field>
    <TCEforms>
    <label>UserFunc Test</label>
    <config>
     <type>user</type>
     <userFunc>EXT:myext/class.tx_userfunc.php:&amp;tx_userfunc->customfield</userFunc>
    </config>
    </TCEforms>
   </userfunc_field>
-- cut --

PHP Script (Saved as: /myext/class.tx_userfunc.php)
-- cut --
<?php
class tx_userfunc {
 function customfield($PA, $fobj) {
  return '<input
     name="'.$PA['itemFormElName'].'"
     value="'.htmlspecialchars(($PA['itemFormElValue'] ? 
$PA['itemFormElValue']:'Default value')).'"
     onchange="'.htmlspecialchars(implode('',$PA['fieldChangeFunc'])).'"
     '.$PA['onFocus'].'
     />';
 }
}
?>
-- cut --

This will create a standard input field. If the field is empty, it will be 
prefiled with the value "'Default value".

--
Peter Klein


"Stig Nørgaard Færch" <snf at dkm.dk> wrote in message 
news:mailman.1.1255001854.16546.typo3-project-templavoila at lists.netfielders.de...
> Dmitry Dulepov skrev:
>> Hi!
>>
>> Stig Nørgaard Færch wrote:
>>> I'm trying to get the current date as default for a input field.
>>> It seems to work for tt_news (datetime field), but if I put this:
>>> mktime(date("H"),date("i"),0,date("m"),date("d"),date("Y"))
>>> into the default field, it will not be processed and will just display
>>> exactly mktime(date("H"),date("i"),0,date("m"),date("d"),date("Y")).
>>
>> You cannot really expect PHP function to be executed in XML ;)
>
> Doh - yes - I see.
> So I guess it's not possible to get dynamic default values?
>
> /Stig 




More information about the TYPO3-project-templavoila mailing list