πŸ‡ΊπŸ‡ΈUnited States @drupol

Account created on 19 March 2015, almost 10 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you! It works. 

Every time I click on Increment, I see the "Please wait " message. How to hide the message without using CSS? When I click on Increment, I just like to see the total count. The same applies to the reset button.

https://ibb.co/9T45Lb4

πŸ‡ΊπŸ‡ΈUnited States drupol

It worked now after the space between Accept key and the first curly brace. Thank you!

POST https://mysite.ddev.site/articles
Content-Type: application/json
Accept: application/json

{
  "title": "My second article7777",
  "body": "Test body"
}
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Sun, 16 Jul 2023 01:08:59 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Content-Encoding: gzip
πŸ‡ΊπŸ‡ΈUnited States drupol

I see an error in Drupal logs when I send the request. Looks like it is complaining about the title being null but I am sending the request with the title. 

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null: INSERT INTO "node_field_data" ("nid", "vid", "type", "langcode", "status", "uid", "title", "created", "changed", "promote", "sticky", "default_langcode", "revision_translation_affected") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12); Array ( [:db_insert_placeholder_0] => 44 [:db_insert_placeholder_1] => 68 [:db_insert_placeholder_2] => article [:db_insert_placeholder_3] => en [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => 1689469344 [:db_insert_placeholder_8] => 1689469344 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 1 [:db_insert_placeholder_12] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you! It worked. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you! It worked now. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Yes, I have. 

services:
  demo.request_subscriber:
    class: Drupal\demo\EventSubscriber\RequestSubscriber
    tags:
      - { name: event_subscriber }
πŸ‡ΊπŸ‡ΈUnited States drupol

I uninstalled the module and reinstalled it a few times. The site is running on Ubuntu/ddev. 

$ ddev drush en demo

  [success] Successfully enabled: demo​

<?php

namespace Drupal\demo\EventSubscriber;

use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Template File Doc Comment
 *
 * PHP version 8.2
 *
 * @category Template_Class
 * @package  Template_Class
 * @author   Author <author@domain.com>
 * @license  https://opensource.org/licenses/MIT MIT License
 * @link     http://localhost/
 */
class RequestSubscriber implements EventSubscriberInterface
{


    /**
     * {@inheritdoc}
     *
     * @return mixed
     */
    public static function getSubscribedEvents()
    {
        return [
        RequestEvent::class => ['doAnonymousRedirect',28],
        ];
    }

    /** // phpcs:ignore
     * Redirects all anonymous users to the login page.
     *
     * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event The event.
     *
     * @return mixed
     */
    public function doAnonymousRedirect(RequestEvent $event)
    {
        echo "Test";

        // Make sure we are not on the user login route.
        if (\Drupal::routeMatch()->getRouteName() ==   'user.login') {
            return;
        }

        // Check if the current user is logged in.
        if (\Drupal::currentUser()->isAnonymous()) {
            // If they are not logged in, create a redirect response.
            // $url = \Drupal\mymodule\EventSubscriber\Url::fromRoute('user.login')->toString();
            $url = Url::fromRoute('user.login')->toString();
            dump($url);
            echo "URL IS " .$url;
            $redirect = new RedirectResponse($url);
            // Set the redirect response on the event, canceling default response.
            $event->setResponse($redirect);
        }
    }
}

I do not know if it is anything to do with the php version. I am using VS Code which throws an error to add php version in the php file. So I added php version above the class name. 

Ubuntu php version:

$ php -version
PHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies

Windows/Command prompt php:

>php -version
PHP 8.2.0 (cli) (built: Dec  6 2022 15:31:23) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies

Directory of the module:

\web\modules\custom\demo

Module code can be found here: https://github.com/rkmm1/d10-demo

πŸ‡ΊπŸ‡ΈUnited States drupol

I added echo "Test"; and dump($url); in the following method to test if my code is being called. It's not printing.

    public function doAnonymousRedirect(RequestEvent $event)
    {
        echo "Test";

        // Make sure we are not on the user login route.
        if (\Drupal::routeMatch()->getRouteName() ==   'user.login') {
            return;
        }

        // Check if the current user is logged in.
        if (\Drupal::currentUser()->isAnonymous()) {
            // If they are not logged in, create a redirect response.
            // $url = \Drupal\mymodule\EventSubscriber\Url::fromRoute('user.login')->toString();
            $url = Url::fromRoute('user.login')->toString();
            dump($url);
            echo "URL IS " .$url;
            $redirect = new RedirectResponse($url);
            // Set the redirect response on the event, canceling default response.
            $event->setResponse($redirect);
        }
    }

Cleared the cache again. 

As an anonymous user, I was on the home page. I clicked the Blogs link in the main menu. I was taken to the Blogs page. I expected to see the dump($url) print out the URL in UI but I did not see it. I think my code is not being called.

Reports -> Recent log:

Does not show any error. 

Any suggestions would be helpful. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you! It worked.

πŸ‡ΊπŸ‡ΈUnited States drupol

I had a fieldgroup /fieldset in the disabled region. While the console is open(no error), I dropped the fieldgroup in a region from disabled. As soon as I dropped the fieldgroup in a region, I get the error in console. 

js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2  Uncaught TypeError: Cannot read properties of undefined (reading 'ownerDocument')
    at He (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2:48181)
    at E.fn.init.after (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2:50421)
    at Object.AJAXRefreshRows (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:6354:25)
    at Drupal.tableDrag.onDrop (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:6282:34)
    at Drupal.tableDrag.dropRow (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2662:12)
    at HTMLDocument.<anonymous> (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2058:57)
    at HTMLDocument.dispatch (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2:43336)
    at y.handle (js_32cQn6NAPvAZBGckEFNcvphjT8M2Xd-86ZomNfZhLP8.js:2:41320)
πŸ‡ΊπŸ‡ΈUnited States drupol

I am using Olivera. Just switched to Claro and I am having the same issue. 

As I drag and drop a field group, it is hard to release the mouse. I even tried to tab or ESC, but still it is not being released and it is end up being dropped in a different region. I spent few hours yesterday and today. I am just stuck. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Do I also need this?

https://www.drupal.org/project/jquery_update β†’

But it does not work with D10

πŸ‡ΊπŸ‡ΈUnited States drupol

I am having the same issue again in a different site.

Drupal 10

Bootstrap 3

Views_bootstrap β†’ Version: 8.x-3.9 Manually installed

Images are not sliding.

πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you!

I see the option to change the admin theme on the Appeareances page. I just changed the default theme to Olivero.

On this page, /node/add/properties_for_sell page I have the title text field,

I then went to /core/themes/olivero/css/base/base.css, added this css to test:

input#edit-title-0-value {
background: red;
}

I see the changes did take effect on UI. When I inspected the title text field element, I see that css is being applied from the below file. I added the css in base.css file, but why am I seeing the below long css file for the above styling?

http://my---site.com/sites/default/files/css/css_Lw0Ic46Ndl43RgxXS22Kd9e...

Also, if you're working with a bootstrap-derived theme, it is not usual to modify the CSS directly. Instead you would use SASS and tweak some file with the extension .scss (but of course I've no way of knowing how you've set up your subtheme).

As to what file and what classes to update or override, you need to familiarize yourself with theme debugging to figure this out.

If possible, could you share some docs for me to learn about it?

πŸ‡ΊπŸ‡ΈUnited States drupol

" the screenshot shows that your site is using the core theme Claro as its Administration theme." How were you able to tell from the screenshot that Claro is the admin theme?

πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you! I will look into those.

πŸ‡ΊπŸ‡ΈUnited States drupol

Following did not work too.

https://www.drupal.org/node/157632 β†’

C:\Projects\drupals\ddev-drupal9>drush eval "\$module_data = \Drupal::config('core.extension')->get('module'); unset(\$module_data['test_module']); \Drupal::configFactory()->getEditable('core.extension')->set('module', \$module_data)->save();"

ParseError: syntax error, unexpected token "\", expecting end of file in C:\Projects\drupals\ddev-drupal9\vendor\drush\drush\src\Commands\core\PhpCommands.php(30) : eval()'d code on line 1 #0 [internal function]: Drush\Commands\core\PhpCommands->evaluate()
#1 C:\Projects\drupals\ddev-drupal9\vendor\consolidation\annotated-command\src\CommandProcessor.php(257): call_user_func_array()
#2 C:\Projects\drupals\ddev-drupal9\vendor\consolidation\annotated-command\src\CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#3 C:\Projects\drupals\ddev-drupal9\vendor\consolidation\annotated-command\src\CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#4 C:\Projects\drupals\ddev-drupal9\vendor\consolidation\annotated-command\src\AnnotatedCommand.php(386): Consolidation\AnnotatedCommand\CommandProcessor->process()
#5 C:\Projects\drupals\ddev-drupal9\vendor\symfony\console\Command\Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#6 C:\Projects\drupals\ddev-drupal9\vendor\symfony\console\Application.php(1039): Symfony\Component\Console\Command\Command->run()
#7 C:\Projects\drupals\ddev-drupal9\vendor\symfony\console\Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#8 C:\Projects\drupals\ddev-drupal9\vendor\symfony\console\Application.php(149): Symfony\Component\Console\Application->doRun()
#9 C:\Projects\drupals\ddev-drupal9\vendor\drush\drush\src\Runtime\Runtime.php(124): Symfony\Component\Console\Application->run()
#10 C:\Projects\drupals\ddev-drupal9\vendor\drush\drush\src\Runtime\Runtime.php(51): Drush\Runtime\Runtime->doRun()
#11 C:\Projects\drupals\ddev-drupal9\vendor\drush\drush\drush.php(77): Drush\Runtime\Runtime->run()
#12 C:\Projects\drupals\ddev-drupal9\vendor\drush\drush\drush(4): require('...')
#13 {main}
 [warning] Drush command terminated abnormally.
ParseError: syntax error, unexpected token "\", expecting end of file in Drush\Commands\core\PhpCommands->evaluate() (line 1 of C:\Projects\drupals\ddev-drupal9\vendor\drush\drush\src\Commands\core\PhpCommands.php(30) : eval()'d code).

πŸ‡ΊπŸ‡ΈUnited States drupol

I did try that already. As you can see above, I already deleted the module by running sql command in database. 

DELETE FROM key_value WHERE name = 'test_module'

I created a folder with a test_module.info.yml file but uninstall page did not show the "test_module" module. So I could not uninstall it. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Okay, thanks!

πŸ‡ΊπŸ‡ΈUnited States drupol

How do you restart DDev? DDev commands do not run when I have the issue. I tried DDev poweroff commands before. It did not do anything. DDev commands work just fine when I start my laptop. DDev commands stop working after system is idle for few hours or overnight. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Worked perfectly. Thank you!

πŸ‡ΊπŸ‡ΈUnited States drupol
            [
                '#type' =>'details',
                '#title' => 'details message',
                '#open' => TRUE,
                '#summary_attributes' =>  [
                    'class' => ['content_wrapper'],
                    'id' => 'contentWrapper',
                ],
                
            ],

Page

I was able to add the attributes. Thank you!

How can I display the content when the container is open by default? Please see the page. 

πŸ‡ΊπŸ‡ΈUnited States drupol

For some reason, I was thinking those keys have to be exact. I just renamed 'content' key to 'details'. Everything worked just fine. 

Thank you!

πŸ‡ΊπŸ‡ΈUnited States drupol

Thank you @jaypan. I will give a try. 

πŸ‡ΊπŸ‡ΈUnited States drupol

Google chrome > inspect -> console tab

Production build 0.71.5 2024