Bug #18042

Selected value of select field not shown in TCEforms

Added by Robert Destigter almost 13 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2008-01-23
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5.0
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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

class.t3lib_transferdata.php.diff (827 Bytes) class.t3lib_transferdata.php.diff Administrator Admin, 2008-10-09 16:08
#1

Updated by Robert Destigter almost 13 years ago

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?

#2

Updated by Robert Destigter almost 13 years ago

So far I have been able to debug it back to the function "renderRecord_selectProc" of the class "t3lib_transferData"

#3

Updated by Robert Destigter almost 13 years ago

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?

#4

Updated by Oliver Hader almost 13 years ago

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?

#5

Updated by Steffen Kamper almost 13 years ago

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>

#6

Updated by Robert Destigter almost 13 years ago

@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.

#7

Updated by Robert Destigter almost 13 years ago

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.

#8

Updated by Stefan Geith almost 13 years ago

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.

#9

Updated by Netresearch GmbH & Co KG about 12 years ago

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>

#10

Updated by Netresearch GmbH & Co KG about 12 years ago

The patch is against Typo3 4.2.1

#11

Updated by Christian Weiske almost 11 years ago

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.

#12

Updated by Andreas Wolf about 9 years ago

  • 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?

#13

Updated by Alexander Opitz over 7 years ago

  • Status changed from Needs Feedback to Closed

No response over one year => closed.

Also available in: Atom PDF