0

I have created data entry form using Drupal 8 Webform (Yaml forms), Part of the form is table field which hosts dynamically generted textfields using jquery shown below:

 $(document).ready(function(){
    var input="";
    var column="";
    $(".add-row").click(function(){
    var new_row =jQuery('<tr>');
    input= jQuery('<input>').attr({type: 'text',name:'names[]'});
    column=jQuery('<td>').append(input);
    input= jQuery('<input>').attr({type: 'text',email:'emails[]'});
    column=jQuery('<td>').append(input);
    new_row.append(column);
        $("table tbody").append(new_row);
    });
});

However, to my surprise when I hit submit button of the form all other fields are submitted except the fields which have been generated dynamically on the table field.It seems Drupal 8 can not recognize the dynamically generated input fields

So my question how can I make Drupal 8 recognize my dynamically generated input fields. I want to see the data in these fields in the database. Please help. Your assistance will be greatly appreciated

0

The WebformSubmissionStorage service uses the list of elements associated with the webform to properly store the data. You are going to have to create an Element and WebformElement plugin definition that defines the element type (ie multiple, composite, etc...) and then attach your JS as a library.

  • Any sample code @jrockowitx - i can not figure out. Otherwise i was thinking of creating a hidden field which will capture the table data (in json format) using jquery during submission – Mundile Jul 12 '17 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.