0

I created a custom composite field with a dozen or so fields, in a custom module extending Drupal\webform\Element\WebformCompositeBase. I need to add a "clone" button to the webform multiple table operations, which when clicked will create a new instance of the webform widget as the "add" button does, except that it is populated with the values existing in the element that is being cloned.

I asked this question in the webform issue queue and @jrockowitz responded

That is very tricky.

First, you would add the new operation via \Drupal\webform\Element\WebformMultiple::buildElementRow and then your would have to examine the $form_state to parse the values of the previous rows.

One trick to adding new functionality like this is to first disable #ajax and get the functionality working without ajax and then enable #ajax.

I'm relatively new to D8 development, so I don't understand how to override or otherwise commandeer \Drupal\webform\Element\WebformMultiple::buildElementRow. I know how to make a child class of it and start to add my customizations to it, but I don't know how to get my class to be the one that is executed in place of WebformMultiple::buildElementRow.

Your Answer

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

Browse other questions tagged or ask your own question.