Bug #3657

<f:form.select does not allow to specify selectedValue

Added by Marcel Rosenberger over 12 years ago. Updated about 11 years ago.

Status:
Resolved
Priority:
Should have
Category:
-
Target version:
-
Start date:
2009-06-14
Due date:
% Done:

0%

Estimated time:
Has patch:

Description

The following code from documentation does not work:

<f:form.select name="paymentOptions" options="{payPal: 'PayPal International Services', visa: 'VISA Card'}" selectedValue="visa" />

Error:

PHP Fatal error:  Uncaught exception 'Tx_Fluid_Core_Parser_Exception' with message 'Argument "selectedValue" 
was not registered.' in typo3\sysext\fluid\Classes\Core\Parser\TemplateParser.php:402


Files

fluid_3657.patch (1.27 KB) fluid_3657.patch adds selected value argument and sets selected if nothing selected Christian Müller, 2009-06-14 01:36
#1

Updated by Christian Müller over 12 years ago

Well, could you try this patch?

I do not think it will be final, as I am not sure about the value of $selectedValue in case of nothing selected (first render of form). Hope the check works with === false...

#2

Updated by Marcel Rosenberger over 12 years ago

After applying the patch no error is thrown anymore. However the "visa" option is not selected.

#3

Updated by Christian Müller over 12 years ago

Marcel R. wrote:

After applying the patch no error is thrown anymore. However the "visa" option is not selected.

A change from

if(($selectedValue === false) && $this->arguments->hasArgument('selectedValue') && ($this->arguments['selectedValue'] === (string)$value)){

to

if(empty($selectedValue) && $this->arguments->hasArgument('selectedValue') && ($this->arguments['selectedValue'] === (string)$value)){

should make it working, but has other non wished effect (will always select options with emtpy or zero value), so the return value of $selectedValue has to be changed I think.

#4

Updated by Bastian Waidelich over 12 years ago

Marcel R. wrote:

The following code from documentation does not work:

the documentation is wrong here. All Form view helpers have an argument "value". Could you please try whether this works:

<f:form.select name="paymentOptions" options="{payPal: 'PayPal International Services', visa: 'VISA Card'}" value="visa" />

btw: have a look at https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/viewhelpertest/ to see all the extisting view helpers in action

#5

Updated by Bastian Waidelich over 12 years ago

  • Status changed from New to Needs Feedback
#6

Updated by Marcel Rosenberger over 12 years ago

With attribute value it's working. I tested:

<f:form.select name="paymentOptions" options="{payPal: 'PayPal International Services', visa: 'VISA Card', master: 'MasterCard'}" value="visa" />

as well as
<f:form.select name="paymentOptions" options="{payPal: 'PayPal International Services', visa: 'VISA Card', master: 'MasterCard'}" value="{0: 'master', 1: 'visa'}" multiple="multiple" />

I would like to see the documentation changed inside SelectViewHelper.php accordingly.

#7

Updated by Bastian Waidelich over 12 years ago

  • Status changed from Needs Feedback to Accepted
  • Assignee set to Bastian Waidelich
#8

Updated by Bastian Waidelich over 12 years ago

  • Status changed from Accepted to Resolved

Inline documentation has been fixed in r2914

#9

Updated by Bastian Waidelich about 12 years ago

  • Project changed from 534 to TYPO3.Fluid
  • Category deleted (432)

Also available in: Atom PDF