christian2222
christian2222

Reputation: 95

Typo3 Flexform Radio Button with itemsProcFunc

I have an extension in typo3. I want to make a radio button selection with the itemsProcFunc:

<radField>
   <label>Radiobuttons</label>
   <config>
    <type>radio</type>
    <itemsProcFunc>CM\Parser\UserFunc\FlexFormUserFunc->getNames</itemsProcFunc>
   </config>
</radField>

Unfortunately I get the following error message:

Item itemsProcFunc of field radField of TCA table tt_content is no array as exepcted

I've tried it also with an selection box:

<dynField>
 <TCEforms>
 <label>dynamic content</label>
 <config>
  <type>select</type>
  <renderType>selectSingle</renderType>
  <itemsProcFunc>CM\Parser\UserFunc\FlexFormUserFunc->getNames</itemsProcFunc>
 </config>
 </TCEforms>
 </dynField>

With the selection box it worked but I get a first entry [invalid value] that I can't remove from the dropdown list. However if I use

  <renderType>selectCheckBox</renderType> 

instead I get no invalid values, but then I can choose more than one option which I don't want to.

The php file behind it looks like this:

   class FlexFormUserFunc {
     function getNames($config) {
      $fileList = array();
      $i=0;
      $pathParts = "";
      foreach(glob(__DIR__ . "/formatClasses/*.php") as $fileName) {
       $pathParts = pathinfo($fileName);
       $fileList[$i] = array( 0 => $pathParts['filename'], 1 => $pathParts['basename'] );
       $i++;
     }

  $config['items'] = array_merge($config['items'],$fileList);
  return $config;
  }
 }

Thanks for any help.

Upvotes: 0

Views: 485

Answers (1)

christian2222
christian2222

Reputation: 95

I found a working solution for this problem. A possible flexform looks like this (I forgot the items-array tag):

    <radField>
    <TCEforms>
    <label>Radiobuttons</label>
    <config>
    <type>radio</type>
    <itemsProcFunc>CM\Parser\UserFunc\FlexFormUserFunc->getNames</itemsProcFunc>
    <items type="array">
    </items>
    </config>
    </TCEforms>
    </radField>

Upvotes: 0

Related Questions