Bug #60556

Form VewiHelpers inside a Widget that is inside a f:form, are unaware of the surrounding form

Added by Christian Loock about 1 year ago. Updated 5 months ago.

Status:Closed Start date:2014-07-25
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:-
Target version:-
PHP Version: Complexity:
Has patch:No Affected Flow version:(any)

Description

When I use a custom widget ViewHelper inside a f:form, I cannot use f:form.* ViewHelpers inside the widget, like I could inside the form itself:

Example. (Assume that foo is an object that has a property bar)

The for:
<f:form action="update" objectName="foo" object="{bar}">
<vendor:widget.baz/>

</f:form>

And inside the widget:

<f:form.textfield propery="bar"/>

Will result in a text field:

<input type="text" name="bar">

instead of

<input type="text" name="foo[bar]">

There should at least be an option to make this possible in widget, to be able to build more complex form controlls, that write into object properties.

History

#1 Updated by Bastian Waidelich about 1 year ago

  • Status changed from New to Needs Feedback
  • Assigned To set to Bastian Waidelich

Hi Christian,

that's the definition of a Fluid widget that it has it's own context with a sub-MVC structure.
If you want to use the surrounding context, you should not create a widget but a regular ViewHelper instead.

What are you trying to achieve?

#2 Updated by Christian Loock 9 months ago

Bastian Waidelich wrote:

Hi Christian,

that's the definition of a Fluid widget that it has it's own context with a sub-MVC structure.
If you want to use the surrounding context, you should not create a widget but a regular ViewHelper instead.

What are you trying to achieve?

Hey,

I understand that Widgets are in their own seperated Request, because they use their own controllers. However, since you basically use them like normal ViewHelpers, it might be usefull to somehow make them aware of their surroundings. For example inside a form, when you want to create custom form fields, that are a bit more complex then your average form html input tags, having the possibility to use ajax widgets would be a big benefit. I usually tend to use Widgets instead of normal ViewHelpers when I want the rendered output to reside in its own Fluid template and/or use Ajax. I know you could use a Standalone View inside a viewhelper to achieve something similar, but that doesnt really feel very clean for me.

#3 Updated by Bastian Waidelich 8 months ago

Hey Christian,

thanks for the feedback! I see your point but I think everything you mention can be achieved today already:
If you want to use an (ajax) widget as form field you can do this by passing the required data to the widget controller. By default all arguments of the render() method are available already (see AutocompleteViewHelper for example) and you pass additional data overriding the getWidgetConfiguration() method.
If you do want to use regular form.* ViewHelpers within the "parent" ViewHelper just don't use a widget but a ViewHelper and call renderChildren() (see https://git.typo3.org/Packages/TYPO3.Form.git/blob/HEAD:/Classes/TYPO3/Form/ViewHelpers/Form/UploadedImageViewHelper.php for example).
To reduce duplication you can use partials.

#4 Updated by Bastian Waidelich 5 months ago

  • Status changed from Needs Feedback to Closed

Closing due to missing feedback. Feel free to comment/re-open if you don't agree

Also available in: Atom PDF