Feature #37506

Building up Nested Forms with this ViewHelper

Added by Carsten Bleicker about 3 years ago. Updated about 3 years ago.

Status:Closed Start date:2012-05-26
Priority:Won't have this time Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:ViewHelpers
Target version:-
Has patch:No

Description

Just want to know what you think about this viewhelper
f.e. you sould be able to pass one object to <f:form object="{person} name="person">
and inside this form you can display subproperties f.e. personName by passing
and use general forms with single property namespace withoud . because of traversing.
it is possible to use it in unlimited depth by:

<f:form action='update' object="{person}" objectName="person" >
<vh:nestedForm name="personName" object="{person.name}">
<vh:nestedForm name="subproperty" object="{person.name.supproperty}">
<vh:nestedForm name="anothersubproperty" object="{person.name.supproperty.anothersubproperty}">

Example usage:

#################################################
  1. Form # #################################################

<f:form action='update' object="{person}" objectName="person" >

&lt;vh:nestedForm name="personName" object="{person.name}"&gt;
&lt;fieldset&gt;
&lt;legend&gt;&lt;f:translate id="person.name" /&gt;&lt;/legend&gt;
&lt;f:render partial="Model/Fieldset/PersonName/Default" /&gt;
&lt;/fieldset&gt;
&lt;/vh:nestedForm&gt;

</f:form>

#################################################
  1. Parial: Model/Fieldset/PersonName/Default #
  2. If uses in nestedForm it it reusable anywhere # #################################################

<label class="control-label" for="firstName"><f:translate id="personName.firstName" />:</label>

<!-- No need for person.name.firstName because namespace will be set by nestedForm -->
<f:form.textfield id="firstName" property="firstName" />

NestedFormViewHelper.php Magnifier - Not final, just an Idea. Comments has to be rewritten. (11.3 kB) Carsten Bleicker, 2012-05-26 15:58

NestedFormViewHelper.php Magnifier (12 kB) Carsten Bleicker, 2012-05-26 16:11

History

#1 Updated by Carsten Bleicker about 3 years ago

Sorry for these stupid inline comments.
Usage now in the comments of attached php file.

#2 Updated by Carsten Bleicker about 3 years ago

  • Assigned To set to Bastian Waidelich

#3 Updated by Bastian Waidelich about 3 years ago

  • Assigned To deleted (Bastian Waidelich)

Hi Carsten,

why isn't that working for you:

1<f:form action='update' object="{person}" objectName="person" >
2 <f:form.textfield property="name.subproperty" />
3</f:form>

?

BTW: Please don't assign issues to us ;)

#4 Updated by Bastian Waidelich about 3 years ago

  • Status changed from New to Needs Feedback

#5 Updated by Carsten Bleicker about 3 years ago

For example i have an address model and want to
use this in an order model.
deliveryAddress
billingAddress

so i can build up just only one partial wich holds any fields.
namespacing is set by nested viewhelper by adding the names from parent namespace.

so i can reduce my partialtemplates from 2 to only one partial.

call it "something like inlineEditing by reusing generalFieldset"

Bastian Waidelich wrote:

Hi Carsten,

why isn't that working for you:
[...]

?

BTW: Please don't assign issues to us ;)

#6 Updated by Bastian Waidelich about 3 years ago

  • Status changed from Needs Feedback to New

Carsten Bleicker wrote:

so i can build up just only one partial wich holds any fields.
namespacing is set by nested viewhelper by adding the names from parent namespace.

I get you. But you should be able to achieve the same with some clever partials:

1<f:form action='update' object="{person}" objectName="person" >
2  <f:render partial="AddressForm" section="formFields" arguments="{propertyPrefix: 'person.'}" />
3</f:form>

Lets see what others think about this

#7 Updated by Carsten Bleicker about 3 years ago

Damn :)
Touché!
i will try this.
sometimes life could be so easy :P
but maybe the viewhelper is still usefull if someone doesnt want to handle these property prefixes :)

Bastian Waidelich wrote:

Carsten Bleicker wrote:

so i can build up just only one partial wich holds any fields.
namespacing is set by nested viewhelper by adding the names from parent namespace.

I get you. But you should be able to achieve the same with some clever partials:
[...]

Lets see what others think about this

#8 Updated by Bastian Waidelich about 3 years ago

  • Status changed from New to Closed
  • Assigned To set to Bastian Waidelich
  • Priority changed from Could have to Won't have this time

Carsten Bleicker wrote:

Damn :)
Touché! i will try this.

I hope you were successful ;)

but maybe the viewhelper is still usefull if someone
doesnt want to handle these property prefixes :)

Absolutely. Lets keep it here for people to find. But I close the issue for now.

Thanks for your input!

Also available in: Atom PDF