Task #9214

Task #26664: Clean up Form ViewHelpers

Task #26658: Make Form ViewHelpers consistent

Improve handling of bound properties in checkbox, radio and select ViewHelpers

Added by Bastian Waidelich over 11 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Must have
Category:
ViewHelpers
Target version:
-
Start date:
2010-08-09
Due date:
% Done:

0%

Estimated time:
Has patch:
No

Description

Currently the behavior for form.checkbox, form.radio & form.select ViewHelpers is not clear and leads to errors when bound to objects. See #8854 for example.

We'll have to define, what output is expected in which case to be able to properly refactor these ViewHelpers.


Files

given_v3.png (15 KB) given_v3.png Bastian Waidelich, 2010-08-09 20:03
form.checkbox_v3.png (29.7 KB) form.checkbox_v3.png Bastian Waidelich, 2010-08-09 20:03
form.radio_v3.png (29.9 KB) form.radio_v3.png Bastian Waidelich, 2010-08-09 20:03
form.select_v3.png (77.7 KB) form.select_v3.png Bastian Waidelich, 2010-08-09 20:03
9214_improve_checkbox_radio_and_select_viewhelpers.xlsx (21.4 KB) 9214_improve_checkbox_radio_and_select_viewhelpers.xlsx Bastian Waidelich, 2010-08-09 20:03
9214_improve_checkbox_radio_and_select_viewhelpers_mf.xls (37.5 KB) 9214_improve_checkbox_radio_and_select_viewhelpers_mf.xls Michael Feinbier, 2010-08-10 11:12

Related issues

Related to TYPO3.Fluid - Bug #8854: form.checkbox ViewHelper throws Exception in newActionResolvedBastian Waidelich2010-07-14

Actions
Related to TYPO3.Fluid - Task #5636: Form_RadioViewHelper and CheckBoxViewHelper miss check for existing object before it is accessed.Under Review2009-12-05

Actions
#1

Updated by Bastian Waidelich over 11 years ago

  • File given_v1.png added
  • File form.checkbox_v1.png added
  • File form.radio_v1.png added

Attached is a first version of an input-output-matrix for checkbox and radio ViewHelpers. A sheet for select ViewHelper follows.

Feel free to comment

#2

Updated by Bastian Waidelich over 11 years ago

  • File given_v2.png added
  • File form.checkbox_v2.png added
  • File form.radio_v2.png added

Added examples for properties of type string/integer after discussion with Michael Feinbier.

#3

Updated by Bastian Waidelich over 11 years ago

  • File deleted (given_v1.png)
#4

Updated by Bastian Waidelich over 11 years ago

  • File deleted (form.checkbox_v1.png)
#5

Updated by Bastian Waidelich over 11 years ago

  • File deleted (form.radio_v1.png)
#6

Updated by Bastian Waidelich over 11 years ago

  • File deleted (given_v2.png)
#7

Updated by Bastian Waidelich over 11 years ago

  • File deleted (form.checkbox_v2.png)
#8

Updated by Bastian Waidelich over 11 years ago

  • File deleted (form.radio_v2.png)
#10

Updated by Michael Feinbier over 11 years ago

Hey

thanks for your work on this :)
I think you missed the value-attribute in the form.select matrix. The combination of both value and option is important for the behaviour of this viewHelper.
I updated your Excel-sheet in the select-tab. I did the matrix for "tags" and "hidden" already. If I find some additional time today I will do the rest oft it.

#11

Updated by Peter Niederlag almost 11 years ago

any updates on this? can we help out somehow?

#12

Updated by Michael Feinbier almost 11 years ago

Hey Peter,

I started to work on this some days ago. Would be nice if you have a look at the matrix and see, if you miss something

#13

Updated by Bastian Waidelich almost 11 years ago

  • Priority changed from Should have to Must have

Michael Feinbier wrote:

I started to work on this some days ago.

That's great. This seems to be one of the burning issues!

#14

Updated by Sebastian Kurfuerst over 10 years ago

  • Target version set to 1.0 beta 2
  • Parent task set to #26658
#15

Updated by Christopher Seidel over 10 years ago

Hi,

i hope this is okay for you but i had problems with the checkbox Viewhelper and ObjectStorages. I wasnt able to bind an ObjectStorage to a checkbox but i made a small solution to fix this problem.

Old code:

} elseif (is_array($propertyValue)) {
                $checked = in_array($valueAttribute, $propertyValue);
                $nameAttribute .= '[]';
            } else {
                throw new Tx_Fluid_Core_ViewHelper_Exception('Checkbox viewhelpers can only be bound to properties of type boolean or array. Property "' . $this->arguments['property'] . '" is of type "' . (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)) . '".' , 1248261038);
            }

New Code with added the elseif


} elseif (is_array($propertyValue)) {
                            $checked = in_array($valueAttribute, $propertyValue);
                            $nameAttribute .= '[]';
                    } elseif(is_object($propertyValue)) {
                            foreach ($propertyValue as $value) {
                                if($valueAttribute == $value->getUid()) {
                                    $checked = $value->getUid();
                                }
                            }
                            $nameAttribute .= '[]';
                    } else {
                            throw new Tx_Fluid_Core_ViewHelper_Exception('Checkbox viewhelpers can only be bound to properties of type boolean or array. Property "' . $this->arguments['property'] . '" is of type "' . (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)) . '".' , 1248261038);
                    }

#16

Updated by Robert Lemke about 10 years ago

  • Target version changed from 1.0 beta 2 to 1.0.0
#17

Updated by Karsten Dambekalns about 10 years ago

  • Target version deleted (1.0.0)
#18

Updated by Bastian Waidelich over 9 years ago

  • Status changed from Accepted to Closed
  • Has patch set to No

Most of this has been resolved in the meantime and the Form framework shows that the Form ViewHelpers work in fact. There are still some glitches, but we should tackle them in smaller change sets.

Also available in: Atom PDF