-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[WIP] Add section for rendering a custom prototype for collections #1998
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
Conversation
.. code-block:: html+jinja | ||
data-prototype="{% filter escape %}{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' with { 'form': form.task.get('prototype') } %}{% endfilter %}" | ||
|
||
The included `AcmeTaskBundle:Task:prototypeTask.html.twig` contains the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must use double backtricks for inline code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Is there anything left todo? /cc @weaverryan |
{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' | ||
with { 'form': form.task.get('prototype') } | ||
%} | ||
{% endfilter %}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a php
format aswell.
@wouterj I'll add an PHP-example along the Twig-example. @weaverryan You mean passing |
I've added PHP examples and also a example prototype. But I still need to test those additions so even if it is mergable. |
); | ||
|
||
echo $view->escape($prototype); | ||
?>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use configuration blocks for the code examples (and use the {# ... #}
format for comments in the twig example):
.. configuration-block::
.. code-block:: html+jinja
{# src/Acme/TaskBundle/Resources/views/Taks/prototypeTask.html.twig #}
...
.. code-block:: html+php
<!-- ... -->
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment syntax only for html+jinja
or for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for Twig examples, more information here: http://symfony.com/doc/current/contributing/documentation/overview.html#standards (4th standard)
I really want this covered in the docs, and I know this approach works (though this PR still needs some tweaks - there are some comments posted that need to be dealt with). But, is this the best way? Is there no way to theme each "task" so that when you render the tasks (or render the prototype), they use the same markup? What we're doing here is basically not form theming, but instead using our own form rendering logic when outputting the prototype and the individual fields. I guess that's ok, but if we could just theme the field, I think it would be easier. |
When customizing the rendering of a single field, the Form component uses {# assuming the root form is named "myform" and the collection field inside it is "tasks" #}
{% block _myform_tasks_entry_widget %}
<tr>
<td>{{ form_widget(form.task) }}</td>
<td>{{ form_widget(form.dueDate) }}</td>
</tr>
{% endblock %} |
@stof So, using the block would make it more usable? If this is the case I'll test it and will update the cookbook-entry accordingly. |
Correctly formatted source code examples.
Added example for prototype template.
603e9fa
to
a4f53b5
Compare
Add note about removing web/bundles/acmedemo directory
Ok, looks like I failed on rebasing. Anything I can do to fix this or would it be better to open a new PR? |
your fail is that you rebase the symfony master branch on top of your branch instead of rebasing your branch. The way to fix this would be to rebase again, doing it with the right branch |
@stof I basically followed the instructions from symfony.com. That is it, no? |
@daFish Hm, do you think that you are able to solve the conflict? It's no problem if you can't do that. We can easily take your changes and rebase it for you. Just let us know what you think. :) |
@xabbuh That would be great if you could that. However, I'd love to learn how to successfully rebase from master for the next time. ;) |
@daFish are you sure you followed exactly the instructions in the doc ? To me, it looks like you ran the |
@daFish Of course, I can do that tonight. Thank you for your nice contribution! I'm pretty sure that the instructions in the documentation do actually work if you follow them step by step though. |
Even with a rebase, this documentation is outdated, don't follow the right way of #1998 (comment) and so very little code stay valid. |
@webda2l I know and this will be fixed when the rebase is done. |
@daFish You can checkout the |
@daFish Do you have time to finish this? |
@xabbuh Unfortunately I won't be able to finish this anytime soon. :( |
@daFish thanks for noting that, we can take this over (no problem). Can you maybe provide a list of things you wanted to do? The only thing I see is rebasing, but I guess there are more things? Thanks again for starting this! |
This PR adds an section to the prototype cookbook-article to describe how to render a custom prototype for dealing with collections.