Feature #37506

Building up Nested Forms with this ViewHelper

Added by Carsten Bleicker over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Won't have this time
Category:
ViewHelpers
Target version:
-
Start date:
2012-05-26
Due date:
% Done:

0%

Estimated time:
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" />


Files

NestedFormViewHelper.php (11.3 KB) NestedFormViewHelper.php Not final, just an Idea. Comments has to be rewritten. Carsten Bleicker, 2012-05-26 15:58
NestedFormViewHelper.php (12 KB) NestedFormViewHelper.php Carsten Bleicker, 2012-05-26 16:11
#1

Updated by Carsten Bleicker over 9 years ago

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

#2

Updated by Carsten Bleicker over 9 years ago

  • Assignee set to Bastian Waidelich
#3

Updated by Bastian Waidelich over 9 years ago

  • Assignee deleted (Bastian Waidelich)

Hi Carsten,

why isn't that working for you:

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

?

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

#4

Updated by Bastian Waidelich over 9 years ago

  • Status changed from New to Needs Feedback
#5

Updated by Carsten Bleicker over 9 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 over 9 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:

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

Lets see what others think about this

#7

Updated by Carsten Bleicker over 9 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 over 9 years ago

  • Status changed from New to Closed
  • Assignee 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