Core API

4.2.13. ['columns'][fieldname]['config'] / TYPE: "user"

Allows you to render a whole form field by a user function or class method.

Key

Datatype

Description

type

string

[Must be set to "user"]

userFunc

string

Function or method reference.

If you want to call a function, just enter the function name. The function name must be prefixed "user_" or "tx_".

If you want to call a method in a class, enter "[classname]->[methodname]". The class name must be prefixed "user_" or "tx_".

 

Two arguments will be passed to the function/method: The first argument is an array (passed by reference) which contains the current information about the current field being rendered. The second argument is a reference to the parent object (an instance of the t3lib_TCEforms class).

 

Notice: You must include the class manually on beforehand!

noTableWrapping

boolean

If set, then the output from the user function will not be wrapped in the usual table - you will have to do that yourself.

 

Now follows a codelisting as example:

Example:

This field is rended by custom PHP code:

 


The configuration in TCA is as simple as this:

     1: 'TEST02' => Array (
     2:     'label' => 'TEST02: ',
     3:     'config' => Array (
     4:         'type' => 'user',
     5:         'userFunc' => 'user_class->user_TCAform_test',
     6:     )
     7: ),

In addition you have to make sure the class "user_class" is included and has the method "user_TCAform_test". This the example above it looked like this:

 

     1: class user_class {
     2:     function user_TCAform_test($PA, $fobj)    {
     3:         return '
     4:             <div style="
     5:                     border: 2px dashed #666666;
     6:                     width : 90%;
     7:                     margin: 5px 5px 5px 5px;
     8:                     padding: 5px 5px 5px 5px;"
     9:                     >
    10:                 <h2>My Own Form Field:</h2>
    11:                 <input
    12:                     name="'.$PA['itemFormElName'].'"
    13:                     value="'.htmlspecialchars($PA['itemFormElValue']).'"
    14:                     onchange="'.htmlspecialchars(implode('',$PA['fieldChangeFunc'])).'"
    15:                     '.$PA['onFocus'].'
    16:                     />
    17:             </div>';
    18:     }
    19: }

This is not the place to dig into more details about user defined forms. By this example you can start yourself up but you will have to figure out by yourself what options are available in the $PA array and how to use them.

To top


Valid XHTML 1.0!