Hello,
I’m wondering if it’s possible to use the FormHelper in javascript to dynamically generates HTML code.
I tried this:
function add_new_language(languageId, languageCodes, language) {
$("#languageslist").append(
'\
<?= $this->Form->input("discovery_books_languages['+ nextLanguage +'][title]", ['label' => __("Titre :"), 'id' =>'discovery_books_languages-"+ nextLanguage +"-title' , 'class' => 'form-control']); ?>\
');
And the generated code is:
<div class="form-group text">
<label class="control-label" for="discovery_books_languages-"+ nextLanguage +"-title">Titre :</label>
<input type="text" name="discovery_books_languages['+ nextLanguage +'][title]" class="form-control form-control" id="discovery_books_languages-"+ nextLanguage +"-title" />
</div>
Almost good except for the id
which is created with html entities instead of ascii character.
Do you see a way to prevent it