This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Could someone clarify how to use data-prototype?

About symfony tutorials, symfony book and API documentation.

Could someone clarify how to use data-prototype?

by gandalf117 » Tue Aug 06, 2013 10:33 am

I keep reading all these Symfony 2 official documentations and they are all written pretty badly. They basically don't clarify or explain almost anything and just give some weird examples that you have to decode. A lot of the time even though I understand what they are doing I don't understand WHY. I do realize though that the code is written by someone much smarter than me and that makes me really wonder why it is the way it is. So I was reading about data-prototype here: (it is basically a short tutorial on how to dynamically add rows and forms that have been pre-built with Symfony 2)

Code: Select all
http://symfony.com/doc/master/cookbook/form/form_collections.html#allowing-new-tags-with-the-prototype


Now, I can easily do all this with javascript or Jquery but without the use of even data-prototype. But I wanted to learn what this data-prototype is about and how to properly use it and also why!

I am new to Symfony but I have plenty of experience with JavaScript and jQuery. Here are some of the things I don't understand:
- first why they have to build and add their button dynamically
- why the data-prototype has to be an attribute? couldn't you just put the code within a random invisible div and take it from there?
- why not do something like this $(".divClass").attr("data-prototype"); and then add this as a new row?
gandalf117
Junior Member
 
Posts: 18
Joined: Mon Jul 15, 2013 3:03 pm