Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:13:30+00:00 2026-06-12T17:13:30+00:00

I’d like to create an admin panel for one of my projects, so I

  • 0

I’d like to create an admin panel for one of my projects, so I started with this tutorial:
How to Embed a Collection of Forms

Continued with creating double embedded form, so i have an object, what have objects, and these objects also have objects 😀
The Doctrine mapping is good, and works, the problem:
When I click on the “Add new Property” it creates the property, but when I click on the “Add Detail” (which adds a detail to the property) it creates the Detail’s fields, but one extra field too:
<label class="required">1label__</label>
The formtype codes:
For the main class

$builder
        ->add('forma')
    ;

    $builder->add('properties', 'collection',array(
        'type' => new PropertyType(),
        'allow_add' => true,
        'allow_delete' => true,
        'by_reference' => false
        ));

For the property class:

$builder
        ->add('nev')
        //->add('szokokut')
    ;

    $builder->add('details', 'collection',array(
        'type' => new DetailType(),
        'allow_add' => true,
        'allow_delete' => true,
        'by_reference' => false
        ));

For the Detail class:

$builder
        ->add('description')
        //->add('property')
    ;

These codes are from the buildFrom() functions.

Any idea why is there the extra field?

The first prototype:

<div id="szokokut_storebundle_szokokuttype_properties___name__"><div><label for="szokokut_storebundle_szokokuttype_properties___name___nev" class="required">Nev</label><input type="text" id="szokokut_storebundle_szokokuttype_properties___name___nev" name="szokokut_storebundle_szokokuttype[properties][__name__][nev]" required="required" maxlength="100" /></div><div><label class="required">Details</label><div id="szokokut_storebundle_szokokuttype_properties___name___details" data-prototype="&lt;div&gt;&lt;label class=&quot;required&quot;&gt;__name__label__&lt;/label&gt;&lt;div id=&quot;szokokut_storebundle_szokokuttype_properties___name___details___name__&quot;&gt;&lt;div&gt;&lt;label for=&quot;szokokut_storebundle_szokokuttype_properties___name___details___name___description&quot; class=&quot;required&quot;&gt;Description&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;szokokut_storebundle_szokokuttype_properties___name___details___name___description&quot; name=&quot;szokokut_storebundle_szokokuttype[properties][__name__][details][__name__][description]&quot; required=&quot;required&quot; maxlength=&quot;100&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;"></div></div></div>

The second:

<div><label class="required">1label__</label><div id="szokokut_storebundle_szokokuttype_properties_1_details_1"><div><label for="szokokut_storebundle_szokokuttype_properties_1_details_1_description" class="required">Description</label><input type="text" id="szokokut_storebundle_szokokuttype_properties_1_details_1_description" name="szokokut_storebundle_szokokuttype[properties][1][details][1][description]" required="required" maxlength="100" /></div></div></div>

The problem will be here:
Its from the tutorial (with a little change) and it replaces the __name__ field in both of the prototypes :/

var $addPropertyLink = $('<a href="#" class="add_property_link">Tulajdonság hozzáadása</a>');
var $newLinkLi = $('<p></p>').append($addPropertyLink);

jQuery(document).ready(function() {
propertyHolder.append($newLinkLi);

$addPropertyLink.on('click', function(e) {
    e.preventDefault();

    addPropertyForm(propertyHolder, $newLinkLi);
    });
});

function addPropertyForm(collectionHolder, $newLinkLi) {
    // Get the data-prototype we explained earlier
    var prototype = collectionHolder.attr('data-prototype');

    // Replace '__name__' in the prototype's HTML to
    // instead be a number based on the current collection's length.
    var newForm = prototype.replace(/__name__/g, collectionHolder.children().length);

    // Display the form in the page in an li
    var $newFormLi = $('<p></p>').append(newForm);
    $newLinkLi.before($newFormLi);
    addFormDeleteLink($newFormLi);
    var $addDetailLink = $('<a href="#" class="add_detail_link">Részlet hozzáadása</a>');
    var $LinkLi = $('<p></p>').append($addDetailLink);
    $newFormLi.find('div[id$=_details]').append($LinkLi);

    $addDetailLink.on('click',function(e){
        e.preventDefault();

        addDetailForm($newFormLi.find('div[id$=_details]'),$LinkLi);
    });



}

function addFormDeleteLink($FormLi) {
    var $removeFormA = $('<a href="#">törlés</a>');
    $FormLi.append($removeFormA);

    $removeFormA.on('click', function(e) {
        // prevent the link from creating a "#" on the URL
        e.preventDefault();

        // remove the li for the tag form
        $FormLi.remove();
    });
}

function addDetailForm(collectionHolder,$newLinkLi){
    // Get the data-prototype we explained earlier
    var prototype = collectionHolder.attr('data-prototype');

    // Replace '__name__' in the prototype's HTML to
    // instead be a number based on the current collection's length.
    var newForm = prototype.replace(/__name__/g, collectionHolder.children().length);

    // Display the form in the page in an li
    var $newFormLi = $('<p></p>').append(newForm);
    $newLinkLi.before($newFormLi);
    addFormDeleteLink($newFormLi);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:13:32+00:00Added an answer on June 12, 2026 at 5:13 pm

    You should try to make sure your javascript only acts on the right set of elements, by using a good enough selector.
    Show your js for a more detailed answer.

    UPDATE
    Look at the code

    There seems to be an undocumented prototype_name option that you can change from name to whatever you want for one of your prototypes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.