baikho
  • Member for 7 years, 9 months
  • Last seen this week
How do I alter the behavior of the form fields contained within the paragraph field?
9 votes

If you are using Paragraphs Browser Field Widgets, then the WIDGET_TYPE ids for hook hook_field_widget_WIDGET_TYPE_form_alter() are different: Field Widget Label Field Widget ID Provider Paragraphs ...

View answer
How to add a js script as type="module"
Accepted answer
6 votes

Yes, it is possible, with the attributes property. my-library: version: 1.x js: js/App.js: { attributes: { type: module } } See Adding attributes to script elements and JS properties.

View answer
Why does #submit apply to all buttons?
Accepted answer
4 votes

Give your submit button a unique and valid #name attribute. I don't think it will work if you put spaces in it: $form['actions']['save'] = [ '#type' => 'submit', '#name' => 'standard-save', ...

View answer
How to programmatically get webform drafts for a specific user?
4 votes

You could try this: $query = \Drupal::entityQuery('webform_submission') ->condition('uid', 123) ->condition('webform_id, 'test_1') ->condition('in_draft', TRUE); $entity_ids = $query-&...

View answer
Get a list of available migration destination plugins
4 votes

With Drupal Console: $ drupal debug:plugin migrate.destination Or short: $ drupal dpl migrate.destination gives: ------------------------------------------ ----------------------------------------...

View answer
Change form list default value
4 votes

In Drupal 8 type-hint $form_state with the FormStateInterface & do not pass it by reference: hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) See ...

View answer
Libraries API not working in my module
Accepted answer
4 votes

Add a composer.json file to your movies module & name it your custom module's name: { "name": "drupal/movies", "type": "drupal-module", "license": "GPL-2.0+", "require": { "imdbphp/...

View answer
How can I query by node title?
Accepted answer
3 votes

This works fine in Drupal 9 for titles only from the node_field_data table: $ drush php Psy Shell v0.10.4 (PHP 7.4.13 — cli) by Justin Hileman >>> $db = \Drupal::database(); => Drupal\Core\...

View answer
How do I access profile fields?
3 votes

You could examine the Profile Entity class here profile / src / Entity / ProfileInterface.php, showing you a list of public methods including its getter methods, eg.: $profile->getCreatedTime(); ...

View answer
Get parent menu item of a current node
Accepted answer
3 votes

I think you need to reset the collection first, as the ::loadLinksByRoute() annotation states that it returns an array of MenuLinkInterfaces[]. See /core/lib/Drupal/Core/Menu/MenuLinkManagerInterface....

View answer
How can a description be added to the body field summary widget in node edit form?
Accepted answer
3 votes

I assume you're using Drupal 8. Try the below in your hook alter. This also assumes the usage of the default body field in use: use Drupal\Core\StringTranslation\TranslatableMarkup; // Ensure summary ...

View answer
Adding ThirdPartySetting to webform entity results in wrong module dependency
2 votes

Please use hook_webform_third_party_settings_form_alter() in mymodule.module and discard the submit handler which should solve that: use Drupal\Core\Form\FormStateInterface; /** * Implements ...

View answer
Installing/Enabling Custom Webform Hander
Accepted answer
2 votes

A few things in addition to what @4k4 commented: Please replace your annotation plugin reference with @WebformHandler Use lower case / snake case names for your Webform Handler ID eg. ...

View answer
How to programmatically copy Webform handler config?
Accepted answer
2 votes

Ended up using the ConfigFactory service, which I believe is fine to do: $config = \Drupal::configFactory()->getEditable('webform.webform.' . $webform->id()); $config_key = 'handlers.' . $...

View answer
How to inject an object into a service?
Accepted answer
2 votes

For this my_module.services.yml file: services: my_module.obj: class: Drupal\my_module\ClassA arguments: ['@http.client'] You can discard the create() method from your A class, because you ...

View answer
Install Issues with OS and Composer 2
2 votes

I can see in your output that you are trying to update to a specific version of Composer and it also prompting an "Access Denied" shortly after: PS C:\> composer self-update 1.4.1 ...

View answer
How do I clear or delete a queue?
2 votes

In Drupal 8, via drush you can do it this way: $ drush queue:delete your_queue_name Or: $ drush php >>> \Drupal::service('queue')->get('your_queue_name')->deleteQueue() => null

View answer
Trying to configure parent link and child links in menu
Accepted answer
2 votes

Your 2nd menu link needs the parent property referencing your first custom_forms_entity_export_csv.export route : custom_forms_entity_export_csv.export_sales_form: title: 'Export Sales' ...

View answer
Adding a new user directly in database
2 votes

If you happen to use drush you can use drush upwd [user] --password="[newpassword]" which (re)sets the password for the user with the specified name. (upwd is the short command version for user-...

View answer
drush config-status on translation / language config files?
Accepted answer
1 votes

The config-status command doesn't show the config's relevant collection, which is how I got confused, but @Patrick Kenny is right, the output does list the language config files. One solution would be ...

View answer
How can I create a Link to an URL containing a fragment identifier?
Accepted answer
1 votes

Please see public static function Link::createFromRoute array $options: The options parameter takes exactly the same structure. See \Drupal\Core\Url::fromUri() for details. You can pass a 4th ...

View answer
How can you prevent a Webform from going to a confirmation modal if remote post handler fails in a service response?
1 votes

I believe it is too late to halt the Webform with validation errors once it is past the validation phase ie. in postSave(). If you are expecting validation errors on user input however, then you could ...

View answer
How to apply patches that are created in core-dev
Accepted answer
1 votes

If the patch weren't already committed, you would need to reroll the desired patch against your Drupal Core version. This can be done by cloning the git repository of Drupal Core and generating a ...

View answer
Webform POST handler, add API/header creds?
Accepted answer
1 votes

Just adding an answer in addition to @Ryan Hartman's comment. Extend the RemotePostWebformHandler class and its ::buildConfigurationForm() method: /** * Custom Webform submission remote post handler. ...

View answer
Programmatically get View Custom Image filed url
Accepted answer
1 votes

Your field_image_ads looks like an entity reference field, so try this: $entity->field_image_ads->entity->getFileUri();

View answer
Updating from core 8.7.9 to 8.8.0
1 votes

I can see you're using acquia/lightning which is not a dependency from core but the other way around, so running that command with the dependencies flag will not work. Run the command as follows: $ ...

View answer
How to check if dynamic select query returns zero records and return markup
1 votes

You could try emitting a warning via the messenger service like: if ($rowCount == 0) { // Alert if no values. \Drupal::messenger()->addWarning($this->t('No entries exist.')); } And then you ...

View answer
How to hide all nodes of a particular content type?
1 votes

Try the Rabbit Hole module: Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page. Perhaps you have a content type that never ...

View answer
$form_state values are empty after ajax $form modification
1 votes

All of your form elements have an '#access' => false attribute. Remove these and your values will pull through in the submit handler.

View answer
Update existing node (not created by Migrate) via Migrate 8.5.x
1 votes

Updating existing content was possible by changing the default behaviour of a migration with the system of record concept in Drupal 7. In Drupal 8 this concept has been revised & is available ...

View answer