Stack Exchange - Drupal Answers
203 FOLLOWERS
Drupal Q&A is a question and answer site for Drupal developers and administrators.
Stack Exchange - Drupal Answers
49m ago
As the title suggests, I'm in the process of upgrading from Drupal 9 to 10 and would like to finally migrate over to Core Media, as opposed to just using inline video/images/files as we have for the last many years.
I have followed the following blog post https://blog.horizontaldigital.com/how-migrate-video-embed-wysiwyg-drupal-core-media but feel like I am missing something as it didn't seem to do anything for me.
I copy and pasted the supplied Update Hook code into a custom module and ran a database update, which told me the hook was applied, however, I don't seem to notice anything changing ..read more
Stack Exchange - Drupal Answers
49m ago
How can I get the field formatter settings inside a field plugin? The field plugin extends FieldItemBase and the corresponding field formatter plugin extends FormatterBase.
If there is no direct way, maybe I could use the entity_display.repository service. But to use the getViewDisplay I need to know which view mode is used. I don't know either how to get the current view mode in the field plugin ..read more
Stack Exchange - Drupal Answers
50m ago
I'm using Drupal 10 and the commerce module. I'm using a product display mode 'card' that uses the variations 'add to cart form' format. In hook_form_alter I am hiding the quantity field:
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if (strpos($form_id, 'commerce_order_item_add_to_cart_form_commerce_product_') === 0) { $form['quantity']['widget'][0]['value']['#type'] = 'hidden'; } }
This works fine, but the problem is that it is obviously hiding the field for every view mode. I would like to only hide it for a my 'card' view mode. How c ..read more
Stack Exchange - Drupal Answers
50m ago
I use Debian 11, PHP 8.1.28, drupal/core-recommended:10.2.6 and drush/drush:12.5.2.
When I run drush archive:dump no error is reported. But when I want to restore the archive with drush archive:restore I receive the following error that seems to be related to the contents of the .tar.gz file:
[warning] PharData::extractTo(/home/drupal/drush-backups/drushTpUnvd/drupal_site/code/web/.gitignore): Failed to open stream: No such file or directory ArchiveRestoreCommands.php:258
In ArchiveRestoreCommands.php line 258:
Extraction from phar "/home/drupal/drush-backups/drupal_site.tar.gz" failed: C ..read more
Stack Exchange - Drupal Answers
50m ago
I'm trying to use Drupal.org's GitLab CI to test a module that has a dependency on a package that requires PHP's ext-sodium to be installed:
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires PHP extension ext-sodium * but it is missing from your system. Install or enable PHP's sodium extensi ..read more
Stack Exchange - Drupal Answers
50m ago
I am looking to set default configuration settings for a contributed module, Nodeaccess, on install. I know that you can do that on site spin-up but this module will not be enabled by default. I tried creating a nodeaccess.settings.yml and placing it in the config/install folder but when I go to enabled the Nodeaccess module, an error notification appears: Unable to install Nodeaccess, nodeaccess.settings already exists in active configuration.
Is there a way to set default configuration settings for Nodeaccess on install? Thanks for your time.
-Chad ..read more
Stack Exchange - Drupal Answers
50m ago
In a site on D9. I have a vocabulary that has titles as the term descriptions.
One of the term descriptions is This & That No matter what I try, the & is converted to & in CKeditor4.
This happens as soon as it's typed. I.e., clicking Source shows the text as
<p>This & That</p>
and the eventual rendering is the same. I've tried all text formats for the CKEditor text, and have, in the Basic filter, turned off any plugins for fixing HTML, etc., No effect.
As to the suggestion of using the raw value. The field in the view is set to rewrite results as such:
{{ desc ..read more
Stack Exchange - Drupal Answers
50m ago
I have created Drupal 9 website. On the website we accept donations using Commerce with Commerce Stripe as the payment processor. By default, the payment button says "Pay and complete purchase". As users are not purchasing anything, I want to change the text to something like "Donate Now". I have searched for answers online but all seem to point to the module String Overrides, which is D7 only and doesn't look like is will have a D8/9 option.
Any idea how to change the text in Drupal 9 ..read more
Stack Exchange - Drupal Answers
50m ago
I want to rename an up-loaded file. I have the following code. I have defined a submit handler to do so.
function example_form_submit(&$form, FormStateInterface $form_state) {
if ($form_state->hasFileElement()) {
$video_file_file_array = $form_state->getValue('field_video_file');
if (is_array($video_file_file_array)) {
if (isset($video_file_file_array[0])) {
$video_file_file_id = $video_file_file_array[0]['fids'][0];
if($video_file_file_id){
$file = \Drupal\file\Entity\File::load($video_file ..read more
Stack Exchange - Drupal Answers
3d ago
Following the scenario for appointment tool
In first step there is a calendar where user select the date.
In second step user selects the time for the date selected.
Remaining steps are contact form and confirmation.
Now the challenging part is - in the first step I need to called the API to get list of available dates and times. I'm planning to build custom form element for date and time selection separately, but the question is where to store email for settings, which I can retrieve for fetch date and time?
Also since single API call is providing both dates and time slots, I want to store ..read more