[TYPO3-dev] TCA condition for input type

Ivano Luberti luberti at archicoop.it
Tue Apr 22 09:28:59 CEST 2014


In the past I have used this hook

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass']

to change the input type on the fly  (i was working with EXT powermail
records but I think you can easily apply this to any backend record).

I have defined my TCA like this

TCA.tx_powermail_domain_model_answers.columns.value{
    config{
          type=user
          size=40
         
userFunc=typo3conf/ext/aippowermail/class.tx_aippowermail.php:tx_aippowermail->specialField
    }


    defaultExtras = richtext[]

 }


TCA.tx_powermail_domain_model_answers.ctrl.label_userFunc=typo3conf/ext/aippowermail/class.tx_aippowermail.php:tx_aippowermail->retrieveFieldName

With the specialField function being like this:

    /**
     *
     * Extract the name of the field to be rendered in PowerMail backend
when editing a mails record
     * See
http://typo3.org/documentation/document-library/core-documentation/doc_core_tca/4.7.1/view/1/3/
     *
     * @param array $PA the parameters configured in the TCA
configuration we are extending
     * @param $fObj reference to the parent object. In our case it
contains a reference tceforms
     *
     * @return String object representing the field to be rendered
     */

    public function specialField($PA, $fObj) {

        $uid = substr($PA['row']['field'], 0,
strpos($PA['row']['field'], '|'));
        $uid = substr($uid, strrpos($uid, '_')+1);

        $record = t3lib_BEfunc::getRecord(self::field_table_name, $uid);

        $table=$PA['table'];
        $field=$PA['field'];
        $row=$PA['row'];
        $tceForms=$PA['pObj'];
        unset($PA['table']);
        unset($PA['field']);
        unset($PA['row']);
        unset($PA['parameters']);
        unset($PA['pObj']);

        if($record['type']=='textarea'){
            return $tceForms->getSingleField_typeText($table, $field,
$row, $PA);
        }else{
            return $tceForms->getSingleField_typeInput($table, $field,
$row, $PA);

        }
    }
}

And I have reused the code in EXT tcamanipulate (no more maintained but
still useful) to trigger the hook and load the custom TCA: this last one
is only because I had to override powermail TCA without modifying the
extension.




Il 21/04/2014 19:55, Philipp Gampe ha scritto:
> Hi Florian,
>
> Florian Schwaiger wrote:
>
>> I thought there might be a different config option, such as a 'typeCond',
>> but there isn't any. I will look into a custom JS handler now.
> Or you use a hook to change the TCA on the fly in tcemain.
>
> Best regards

-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================




More information about the TYPO3-dev mailing list