New answers tagged

0

I've got a webform called "test", and the following query works for me: { webformById(webform_id:"test"){ webform{ elements{ keys } } } } It returns the following (truncated): { "data": { "webformById": { "webform": { "elements": [ { "keys": [ "#type", "#...


0

Ok here is one way to do it does however involve creating a custom twig Extension. its not to hard and there are a few youtube videos on the subject ... for others it is good to note that custom Twig Extensions has replaced php input fields in older versions of Drupal. in a nut shell you create a custom module, you add a MODULENAME.services.yml file. ...


0

ok so here is how to do that.. you need to create a module and set Drupal cron to run once a day on your hosting provider then you need your webform to have email unique then do this .... /** * Implements hook_cron(). */ function YOURMODULE_cron() { $current_month = date('m'); // Get first month of quarter $new_month = (3 * floor(($current_month - ...


0

After trawling through the Webform source think I have an answer. /** * Update using hook_update_N for mymodule to add more options to a webform custom composite. */ function mymodule_update_8001() { . . . // Update a composite element in a webform $webform = \Drupal::entityTypeManager()->getStorage('webform')->load('webform_id'); ...


0

The issue is coming from Drupal core and is fixed in Drupal 8.8. @see Issue #2174633: View output is not used for entityreference options


1

Use [current-page:query:foo] in Default Value field and set query string to node/1?foo=1,2 and it will work. Installing Tokens module will show you some values you can use in your default value field.


2

You can use form alter to access $form array and display/hide specific elements, more details: https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-programmatically-hide-and-show-webform-elements. function CUSTOM_MODULE_form_webform_submission_WEBFORM_NAME_add_form_alter(array &$form, FormStateInterface $form_state, $form_id) { $...


0

If you want to get the path to the module who create the form. You need to access to form_state you can do it in hook_form_alter for example: /** * Implements hook_form_alter(). */ function YouModule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if ($form_id == 'your_form_id'){ // This the class of your form ...


0

You can solve this by implementing hook_form_alter in a custom module. Inside the hook you can use print_r($form_id) to get the form ID for the form page. That should give you an idea of what module the form comes from. Usually form ID’s are named, MODULE_NAME_.... Hope it helps you to find the form.


0

You can try to implement hook_entity_field_access function hook_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, \Drupal\Core\Session\AccountInterface $account, \Drupal\Core\Field\FieldItemListInterface $items = NULL) { if ($field_definition->getName() === 'field_registration_form' && $operation === ...


0

I dedicate a blogpost on how to add a custom WebformSubmitHandler to process the data. Read about it here: https://stefvanlooveren.me/blog/how-create-mailchimp-subscription-drupal-8-webform-module


0

This works (below, added to MY_THEME.theme), but I haven't stress-tested it: function TEMPLATE_preprocess_node(&$variables) { // Hide field_registration_form if already submitted to it. if($variables['node']->bundle() == 'CONTENT_TYPE') { $current_user = \Drupal::currentUser(); $uid = $current_user->id(); $webform = Webform::load('...


0

You could try the Webform Import module for Drupal 7: https://www.drupal.org/project/webform_import


0

When you are in the preview page, you're too late then. You need to set this in your previous step in a validate function function webform_certificadoemail_webform_element_alter(array &$element, FormStateInterface $form_state, array $context) { if ($form_state->get('current_page') == 'step_1') { // or whatever you called the first page $...


0

Webforms now has a "prepopulate" option for most fields. Use the URL query string to populate a field that has been enabled for prepopulation


0

I think it's possible to add this attribute to all input fields using a bit of JS, something like this should work: (function($, Drupal) { Drupal.behaviors.autocompleteFieldBehavior = { attach: function (context) { $(context).find('input').each(function () { var name = $(this).attr('name'); if ($(this).attr('autocomplete').length ...


0

Alternative to Form Hook, you can use the webform-form-{form-id}.tpl.php template file to accommodate your changes. For Example, $form['submitted']['name']['#prefix'] = '<div class="form-group">'; $form['submitted']['name']['#suffix'] = '</div>'; $form['submitted']['name']['#attributes']['class'][] = 'form-control snow_form_control'; Like ...


1

You can keep the field set to single choice, and use hook_webform_submission_render_alter() to display the values as if it was still a multi-select field. You can use the hook in a module or the template.php of a theme. If you are thinking about implementing it in a theme, keep in mind that the Webform Results view is displayed through the Administration ...


0

You could instead create a new component for the single choice option, and disable the multi-option one.


1

You'll notice that for anonymous visitors, webform does store a cookie so that it knows if you've submitted a particular form (assuming a default webform configuration). So in theory, you could hook into that with some custom code to display and/or hide content.


3

The WebformSubmission::resave() method prevents the ::save and ::postSave recursion issue from occuring.


0

I suppose the elements documentations is a bit misleading. You can always try debugging like this: {{ context|keys|join('+') }} {{ data|keys|join('+') }} {{ data|join('+') }} which brought me to conditions like {% if data.mycheckboxes %} {% if mykey in data.mycheckboxes %}


1

$media_id = \Drupal::request()->get('media'); // get value of media query param $media = Drupal\media\Entity\Media::load($media_id); // load the Media entity $media_name = $media->getName(); // get the media item name $media_field = $media->get('field_media_image')->first()->getValue(); // get media field $file_id = $media_field['target_id'...


3

You can create a form alter function in your module file and then add the callback property to the respective field $form['actions']['submit']['#ajax'] = [ 'callback' => 'callback', 'event' => 'click', ]; See also Alter Ajax callback on Webforms How do I add an AJAX action on a select element in a ContentEntityForm to change the value of ...


0

I'm answering this with how I solved it in case anyone else has the same question. Maybe my question could be worded better though... I was able to get this working with the Webform Node module. I installed webform node. Then, I added a webform field to my content type. I selected the form I wanted as the default field settings. I selected the "Use this ...


0

I just ran into this error...just change t('Name') to 'Name' and it should work. Apparently the translate function expands out to an object (instead of what you might expect...'Name' or 'Nombre'...etc): and dumping objects to yaml is apparently no longer "allowed". Ex: Drupal\Core\StringTranslation\TranslatableMarkup Object ( [translatedMarkup:...


Top 50 recent answers are included