Flexforms
Flexforms are useful. They let you create more powerful plugins in a more flexible way. Check this out how to do a basic setup.
Recently there is no automatisation to create flexforms for your extensions, you have to code them by hand. (Well, Templavoila does it to a certain point and you can learn a lot from it, but it does not create custom flexforms for the extension you want to build).
Basically a flexform is a "transposition" of a TCA-array (you can find one in every extension, its name is tca.php). TCA arrays are responsible for the look, feel & function of the interface of plugins and content elements.
A typical TCA array entry can look like this one:
- ...
- "category" => Array (
- "exclude" => 1,
- "label" => "LLL:EXT:vwdtest/locallang_db.php:tx_vwdtest.description",
- "config" => Array (
- "type" => "select",
- "items" => Array (
- Array("",0),
- ),
- "foreign_table" => "tx_another_table",
- "foreign_table_where" => "ORDER BY tx_another_table.uid",
- "size" => 1,
- "minitems" => 0,
- "maxitems" => 1,
- ),
- ...
A flexform does the same thing as a TCA array element does, however it does it in another mode.
The example from above btw. creates a pulldown menu (because of having size=1, minitems=0 and maxitens=1; play with it and check out what it wil do. Do not forget to clear the backend cache (the red trashbin down the left hand main menu) - otherwise nothing will change!
Then it is an element which can be excluded for backend user groups (because of exclude = 1). The dopdown will take its data from a foreign database table and will show elements ordered by uid. Yes, and finally there will be first a blank line in the dropdown because of array("",0) which means that the first element has no text in it.
Now, written in Flexform (i.e. XML) syntax, the same element looks like this:
- ...
- <category type="Array">
- <exclude>1</exclude>
- <label>LLL:EXT:vwdtest/locallang_db.php:tx_vwdtest.description</label> <config>
- <type>select</type>
- <items type="Array">
- <numIndex index="0"></numIndex>
- <numIndex index="1"></numIndex>
- </items>
- <foreign_table>tx_another_table</foreign_table>
- <foreign_table_where>ORDER BY tx_another_table.uid</foreign_table_where>
- <size>1</size>
- <minitems>0</minitems>
- <maxitems>1</maxitems>
- </config>
- </category>
- ...
You can see that it is basically the same. The advantage of Flexforms is that you can alter them dynamically at runtime (see tt_news plugin how to do this via an itemProcsFunc ).
If you want to know more on this topic have a look at the Core API which seems a bit hidden in the overwhelming flood of TYPO3 documentation.
Have phpun!
PS: And thanks for corrections to mtness ;)
