This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

How do I get the current Locale?

I need to find out the current locale.

I believe calling this function will do it for me: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Validatio...

However:

$locale = \DrupalTranslator::getLocale();

produces:

Buttons in custom form

In a custom form I have 3 buttons. and each calls a function.
In the validate of the form, I have inserted the control on a field before the processing takes place but it is only needed when I click on the first button.
When I click on the 2nd or 3rd button it does the same check but does not have to check.
I thought in validate to insert the check on which button was clicked and only for the first to check.
With kint I visualized the array
ksm ($form['submit']['#submit']);

img src adding quotes and spaces when rendered D9

Drupal 9

I'm creating a drupal module that calls a php file to render an image.

current code:

$callphp .= '<img src="/path/path/path/test.php?a=0065&b=15>';

$output .= t($callphp);

return $output

the file is never called so I checked the elements in the browser and spaces and quotes are being added to look like:

<img src=" path path path test.php?a="0065&b=15">

I run a clean install of Open Social and get this when finally visitng the website.

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "post_type" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 143 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Double submit in a custom form

Hi, I have written a custom form and I would like to insert a double button to submit.
The first they call it submit1 and the second submit2
The first has to call me the function

public function submitForm(array &$form, FormStateInterface $form_state) {

and the second

public function submit1Form(array &$form, FormStateInterface $form_state) {

It's possible?

Styling a paragraph link field

Hi,

I am quite new to Drupal and was looking for some help with Paragraphs and Twig templates.

I've got a Paragraph link field I am trying to add some styling to by altering the Twig template. The Paragraph name is ms_useful_resources and the field name is field_ms_links_multi.

I've created a twig template called paragraph--ms-useful-resources.html.twig which has this code:

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions