Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added parameter to setRendered(). Now rendered could already set to false and prototypes could be rendered multiple times. #8676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

web-mi
Copy link

@web-mi web-mi commented Aug 6, 2013

I need this because i had my own field type which is generated dynamically and i wan't to render the protoype for this field type multiple times.

{{ form_widget(form.vars.prototype, {'groups': groups}) | e }}

If i can't reset the rendered value i can't generate the prototype multiple times with dynamic values. I have to set the values with javascript or something else.

@hacfi
Copy link
Contributor

hacfi commented Aug 7, 2013

@itze88 Sorry to disappoint you but it has been suggested and declined previously: #8128

@fabpot fabpot closed this Aug 8, 2013
@web-mi
Copy link
Author

web-mi commented Aug 12, 2013

@hacfi The declined pr was to individual. He only needs this to render his form fields when he needs it. My example is more global and makes sense to render prototype multiple.

@fabpot Did you read my example carefully or do you have closed the pr because you already closed it in the past?
Maybe there is another solution. Return always true if type is prototype form or something else. But i think its useful if you could render prototype multiple with different parameters.

I build my own fix for this by creating multiple forms in my controller and only render the individual prototype forms in my view. Now i have multiple prototypes.

@hacfi
Copy link
Contributor

hacfi commented Aug 12, 2013

@itze88 The code changes were exactly the same as yours. Personally I also wanted to have a setRendered($value) method some time ago but there was another solution in my case.

Isn’t it possible to assign the prototype to a variable and render it several times? Or instead of rendering it assign the output to a variable and output the variable several times? In my code I used {% set prototype = form.field.vars.prototype %} and change a few things before rendering it.

@web-mi
Copy link
Author

web-mi commented Aug 12, 2013

I already tried this solution but it did not work for me. Is rendered were always true. Then i create a twig method to clone the formview. The result was always the same. I don't know why but everything i tried fails on isRendered = true.
And if i tried to set
{% set prototype = form.field.vars.prototype %}
it fails on
if ($hasChildren) {
but i had no time to search where hasChildren isset because why hasChildren isset on my cloned formView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants