Bug #18042
closed
Selected value of select field not shown in TCEforms
Added by Robert Destigter almost 17 years ago.
Updated over 11 years ago.
Category:
FormEngine aka TCEforms
Description
I am having trouble with display selected values in a form field of type "select" within a flexform.
The XML defination of the field in my DS is as follows:
<my_field type="array">
<tx_templavoila type="array">
<title>My field</title>
<eType>select</eType>
</tx_templavoila>
<TCEforms type="array">
<config type="array">
<type>select</type>
<itemsProcFunc>fileadmin/classes/class.myclassfile.php:user_myfunction->
myItems</itemsProcFunc>
<items></items>
<size>10</size>
<maxitems>100</maxitems>
<renderMode>singlebox</renderMode>
</config>
<label>My field</label>
</TCEforms>
</my_field>
The field is displayed correctly with the items passed on with "itemsProcFunc". The selected values are even saved in the XML in the database. I checked that with the option "View: Flexform XML", but the options of the selectbox aren't set as selected after saving.
I also tried the option "<renderMode>checkbox</renderMode>", but even than the selected options aren't checked after saving.
John
(issue imported from #M7248)
Files
Sorry, I accidently submitted before thinking of a good subject. Severity also should be set to major. Could some admin please change this for me?
So far I have been able to debug it back to the function "renderRecord_selectProc" of the class "t3lib_transferData"
The problem has to do with the function "renderRecord_selectProc" of the class "t3lib_transferData".
Because the items array of the field is declared with XML and not set as an empty array by php the function bypasses the step where it loops through the variable $elements.
I solved it with a workaround by changing "<items></items>" into:
<items>
<item>
<numIndex index="0"></numIndex>
</item>
</items>
What is the correct way for this?
Changed the subject of this issue. It's not a major one.
Thanks for tracking down the origin. This would also mean, that an empty items array in regular TCA context produces this behaviour, wouldn't it?
remove <items></items> or if you need an empty item at the beginning use
<items>
<numIndex index="0" type="array">
<numIndex index="0"></numIndex>
<numIndex index="1"></numIndex>
</numIndex>
</items>
@Steffen
Thanks for the info. It worked.
@Oliver
That is correct. I tested the configuration for a regular TCA field defined in PHP. If the index "items" is not declared or if it is not declared as an array, the selected values are submitted to the database, but not displayed as selected after saving or editing the record.
I also tested it in combination with a "foreign_table" configuration. In that case the selected records are displayed as selected, but the selected dynamic options added with "itemsProcFunc" are not.
The renderMode configuration does not have influence on this issue.
My conclusion is: If the "items" index is not an array, selected values added with itemsProcFunc are submitted to the database, but not displayed as selected in the form.
I think, the same behaviour can be seen in tt_news:
When you place the tt_news plugin, you can select a category form the recursive category-tree via 'Category selection' :
but when you re-edit the record, the selection is gone.
If you select 'Special options: [not categorized]' (what is defined in the flexforms items-array) it apears correctly on re-editing.
The problem lies in class.t3lib_transferdata.php:423(function renderRecord_selectProc)
// Add regular elements:
if (is_array($fieldConfig['config']['items'])) {
$fieldConfig['config']['items'] = $this->procesItemArray($fieldConfig['config']['items'], $fieldConfig['config'], $TSconfig[$field], $table, $row, $field);
foreach($fieldConfig['config']['items'] as $pvpv) {
That means only if an item array exists, the dynamic items from itemProcFunction will be added. But that way is false.
A Workaround for that is:
<config type="array">
<type>select</type>
<items type="array">
</items>
<itemsProcFunc>fileadmin/classes/class.myclassfile.php:user_myfunction->
myItems</itemsProcFunc>
<size>10</size>
<maxitems>100</maxitems>
</config>
The patch is against Typo3 4.2.1
Could someone apply this patch to 4.2.x and check if that is still relevant for 4.3? This is a really, really annoying problem.
- Category set to FormEngine aka TCEforms
- Status changed from New to Needs Feedback
- Target version deleted (
0)
- Complexity set to easy
Could anyone provide a test extension for that? And test if that's still relevant in 4.5/4.6?
- Status changed from Needs Feedback to Closed
No response over one year => closed.
Also available in: Atom
PDF