0
votes

The TCA field for one of my records is as follows :

'page_id' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:calendar/Resources/Private/Language/locallang_db.xlf:tx_calendar_domain_model_display.page_id',
            'config' => array(
                'type' => 'user',
                'userFunc' => 'EXT:calendar/class.tx_calendars_tca.php:tx_calendars_tca->someWizard',
            ),

The function someWizard looks like this :

    function someWizard($PA, $fObj) {


        $content='<select>' .
                '<option value="One" > item 1 </option>' .
                '<option value="Two" > item 2 </option>' .
                '<option value="Three" > item 55 </option>' .
                '</select>';


        return $content;
}

The select list renders fine into the backend form, but it does not store anything when saved.It might be that the list is being displayed but the values are not getting set.

EDIT:

I am trying to get all the pages title into a drop-down list, with some conditions and processing. The pseudo code of what i'm thinking to do is something like this.(I still need to do lot of processing to the list)

function someWizard($PA, $fObj) {


                $GLOBALS['TYPO3_DB']->debugOutput = TRUE;
                $formField='<select>';  
                 $PA['fieldConf']['config']['type'] = 'select';

                try{
                    $where='is_siteroot=1';
                    $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','pages',$where);
                    while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                        $formField.='<option value='.$row['uid'].'>'.$row['title'].'</option>';
                    }
                }

                catch(Exception $e){
                    echo $e;
                }


                $formField.='</select>';
                return $formField;

    }

If in my TCA, I give 'type' => 'select' it doesn't render anything.

2

2 Answers

0
votes

The code you are using will of course just show the selector. Even if this construct would be able to save the data, you would have to provide at least some basic information about where to store it. So at least a "name" attribute for the "select" would be cool.

You should change the field type to "select" instead of user and use itemsProcFunc to manipulate the array of available items.

Find more information here: http://docs.typo3.org/typo3cms/TCAReference/

0
votes

The element has no name so there is no chance to be stored. If you only want to modify the items in the list, go with Joey's answer. If you want to change the configuration of the field somewhat more depending on some criteria (e.g. from a select box if there is many items to checkboxes if there's only few), the best is to use TYPO3's method to create the element:

function someWizard($PA, $fObj) {
  $PA['fieldConf']['config']['type'] = 'select';
  $content = $fobj->getSingleField_typeInput('TABLE_NAME', $PA['field'], false, $PA);
  return $content;
}
  • Replace TABLE_NAME with the name of your table.
  • Leave all the other default configuration in your TCA setup.
  • Debug $PA to see what's inside and what you should change on the fly.