🇸🇰Slovakia @coaston

Account created on 25 February 2019, over 6 years ago
#

Recent comments

🇸🇰Slovakia coaston

Actually I experienced the same issue as reported in #20 but when i tried with a new model it worked it seems. To be honest i have tried to clear cache, later to remove all cache from browser, new model - and it works now, not sure which step did resolve that, but looks like like a cache issue..

🇸🇰Slovakia coaston

Hello,

I am experiencing the same. In my case, I need to create access codes using the access_code module and I do not actually require an email address.

I understand that by default, an email is not required when creating a new user as an administrator, as you described above. However, I don't believe this is a core bug; I would rather call it a feature.

Therefore, I'm not sure why an email is necessary when using ECA—could this not be optional even when operating as an administrator?

🇸🇰Slovakia coaston

Thank you for your update and hardwork, much appreciated.

🇸🇰Slovakia coaston

You are right - this workaround works.

So now i need to wait until 3555371 🐛 Can't make calculations, tokens are not properly resolved Active is resolved to continue.

🇸🇰Slovakia coaston

Thank you.

However, I am not sure if this is related to Tokens, because you do not need to use Tokens for this. A simple test, such as just trying 5 + 5 (addition), still fails to save the model, even when no Tokens are involved.

🇸🇰Slovakia coaston

Note: When I tried with "Substraction" it works with the direct number, but it seems it does not work with tokens at all!

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

Maybe the same issue - translate. Try without filter and move down to check one by one.

🇸🇰Slovakia coaston

You saved my day!

That stupid translate module. I couldn't find it at all—when I tested before, I had the English version. However, everything else seems to be in English; only this 'remove a role from the selected users' is being translated, and the translation is very poor.

It works now! You cannot even imagine how stressed I was, because I knew this was possible, yet I spent hours on it yesterday and the deadline is approaching.

THANK YOU

🇸🇰Slovakia coaston

Thanks, this actually works, and I do recall I used it in the past. However, now I need to remove a role because premium features have expired—and it does not work, so that's why I tested it.

Does this mean we currently cannot use any Pre-configured actions for adding/removing roles?

This actually created a huge issue, because I'm not sure how to remove the premium role from the user now. When I tested it some time ago, it worked, so I decided to create such a feature for our client now, but...

🇸🇰Slovakia coaston

Hello,

Please release a new version.

🇸🇰Slovakia coaston

Any patch for D11?

🇸🇰Slovakia coaston

Hi,

I am experiencing the same issue with 3.0.5.

Problem : Unable to add or remove role for a user.

Attached picture of very simple model > User login > add role. Unable to save that model at all with 3.0.5 version.

🇸🇰Slovakia coaston

Any patch ?

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

can anyone merge and release a new version please ?

🇸🇰Slovakia coaston

Patch #15 worked and message issue disappear from logs but Filter still does not work - it won't show any result. So this patch fixed just "message" it seems.

🇸🇰Slovakia coaston

You just saved my day! Thank you, much appreciated.

Note: Config has to be enabled here first : admin/config/media/media-settings/media-download-all

🇸🇰Slovakia coaston

AI TOLD ME TO USE THIS CODE INSTAD, so please review and create patch if it is ok:
/media_canonical_download/src/Controller/MediaCanonicalDownloadController.php

<?php

namespace Drupal\media_canonical_download\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Field\BaseFieldDefinition;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Drupal\file\Plugin\Field\FieldType\FileFieldItemList;
use Drupal\media\MediaInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Returns responses for COS Media as File routes.
 */
class MediaCanonicalDownloadController extends ControllerBase {

  /**
   * Entity type manager service.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Module handler service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Current user service.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    // Odstránil som starú statickú inštanciu a použijeme bežný DI pattern.
    $instance = parent::create($container);
    
    // Injekcia služieb cez setter metódu (aj keď pre jednoduchý DI v create stačí len vrátiť instanciu
    // a použiť konštruktor, pre zachovanie pôvodnej štruktúry to upravíme)
    $instance->entityTypeManager = $container->get('entity_type.manager');
    $instance->configFactory = $container->get('config.factory');
    $instance->moduleHandler = $container->get('module_handler');
    $instance->currentUser = $container->get('current_user');

    return $instance;
  }

  /**
   * Builds the response.
   *
   * Opravené na explicitne nullable parametre, aby sa odstránila Deprecation Warning.
   */
  public function build(?MediaInterface $media = NULL, ?Request $request = NULL) {
    // Ak sa entita nenašla (čo by nemala nastať, ak je trasa správna,
    // ale pre istotu sa to ošetrí)
    if (is_null($media)) {
        return new Response('Media not found.', 404);
    }
    
    $config = $this->configFactory->get('media_canonical_download.settings');
    $settings = $config->get($media->bundle());
    $enabled = $settings['enabled'] ?? FALSE;
    $overrides = $settings['overrides'] ?? [];
    $ret = [];

    foreach ($media->getFieldDefinitions() as $field_name => $definition) {
      if ($field_name != 'thumbnail' && !($definition instanceof BaseFieldDefinition) && ($field = $media->get($field_name)) instanceof FileFieldItemList) {
        // Tu bola implicitná nullable anotácia
        $file = $field->entity ?? NULL;
        $uri = ($file->uri->value ?? NULL);

        if ($file) {
          $mime = $file->getMimeType();
          $ext = pathinfo($uri, PATHINFO_EXTENSION);

          // Ponechávam pôvodnú logiku
          if ($enabled xor (($ext && in_array($ext, $overrides)) || ($mime && in_array($mime, $overrides)))) {
            $ret = [
              'uri' => $uri,
              'status' => 200,
              'headers' => [
                'Content-Type' => $file->getMimeType(),
                'Content-Length' => $file->getSize(),
                'Cache-Control' => 'private',
              ],
            ];

            break;
          }
        }
      }
    }

    $this->moduleHandler->alter('media_canonical_download', $ret, $media, $this->currentUser, $request);

    if ($ret instanceof Response) {
      return $ret;
    }

    if (!empty($ret) && !empty($ret['uri'] ?? NULL)) {
      // Použijeme service namiesto priamej funkcie
      $file_system = $this->container->get('file_system');
      $real_path = $file_system->realpath($ret['uri']);

      if (!file_exists($real_path)) {
        return new Response('Expected file does not exist.', 500);
      }
      
      // BinaryFileResponse prijíma len cestu, nie URI, preto sme použili realpath
      return new BinaryFileResponse($real_path, $ret['status'] ?? NULL, $ret['headers'] ?? []);
    }

    // Ak sa sťahovanie nevynúti, vráti sa štandardný pohľad
    return $this->entityTypeManager->getViewBuilder('media')->view($media);
  }

}

Actually this was changed:

Function: build():

-: public function build(MediaInterface $media = NULL, Request $request = NULL)

+: public function build(?MediaInterface $media = NULL, ?Request $request = NULL)

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

Now there is also possibility to use ECA and it has extra field. However i like this one.

🇸🇰Slovakia coaston

Thank you for your effort.

However, I don't have D11. This issue was originally raised with the 2.1x, so I am unable to test it now.
A backport would be helpful if anyone can confirm that it works as expected.

🇸🇰Slovakia coaston

Thank you, much appreciated. It now works as expected for the custom_field module as well.
You just saved my day!

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

You are right, it seems it works fine with version 2.0.8 and I can see tables from the second database, however unable to test it because of issue reported in #4.

🇸🇰Slovakia coaston

Hello,

First of all thank you for your quick response. However I have red instructions before I installed module so not sure why you think, my table don't have any primary key. It does :
1.

2.First problem is that table with version 2.0.8 cannot be scanned if there is missing "database prefix" as follow:

3.So you have to add prefix - database, which was not really needed with version 2.0.5 but okey :

4.Now once i save it i will be forwarded to main page, but it says table is created with warning, but i an unable to see that table and remove it, hence rollback of database is needed or uninstall/install module again which means all previously created tables are gone (if you move from 2.0.5 to 2.0.8)

5.if I navigate to "All Views Custom Tables" tab as follow:

6. there is following error:

7.If I navigate to "Settings" tab there are a lot of errors:

However I am using Drupal 10.4.6 and Php 8.1.27. Do you think it could be php related ?
I cannot currently upgrade because of stakeholders.

🇸🇰Slovakia coaston

Thank you because it seems decimal does not work at all..

🇸🇰Slovakia coaston

Btw it does not work with decimal like "10.2" is that expected behavior or should I raise additional bug ?

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

hi,

I just tried

<div class="progress-circle">
   <div class="progress-circle__wrapper">
      <div class="progress-circle__value">10</div>
    </div>
</div>

and it works as expected for me.

🇸🇰Slovakia coaston

Thank you. Do you think it is possible that one day this feature will be avaiable or this module is build in a way that this feature wont work?

🇸🇰Slovakia coaston

coaston created an issue.

🇸🇰Slovakia coaston

Thank you so much for your detailed step by step.

I am not using a view field view module, just simple twig:

{% set nidid = nid|render|striptags|spaceless %}
{{ drupal_view('view_name', 'embed_1',nidid) }}

However when I change "embed_1" to "block_1'" it works as expected.
So once again Thank you.

🇸🇰Slovakia coaston

But can you be so kind and answer my questions?

🇸🇰Slovakia coaston

I just tested with Views Vanilla JavaScript Tabs only for 2 views. Separetelly both views works fine, but if you try embed one view into another the second view will change"Views Vanilla JavaScript Tabs" into "href" only.

and if I render one view to antoher - tabs will be changed to href:

🇸🇰Slovakia coaston

still the same issue. merge request did not fix it.

🇸🇰Slovakia coaston

I see, also I have notice, that my web pages where "field group" is used is slower now. Does anyone experience the same issue after applied this patch?

🇸🇰Slovakia coaston

Thank You, I can also confirm MR539983 works as expected.

🇸🇰Slovakia coaston

for me patch #68 did not work for Date field and entity reference so I asked AI for a help and this part of code has been changed from patch #68

Original :

+    // Get the views ResultRow.
+    $results_row = $form['output'][0]['#view']->result[$row] ?? NULL;
+
+    // Find the entity we are updating from the ResultRow.
+    if ($results_row instanceof ResultRow) {
+      if (!empty($trigger['#relationship']) && $trigger['#relationship'] != 'none') {
+        $entity = $results_row->_relationship_entities[$trigger['#relationship']];
+      }
+      elseif (!empty($trigger['#ajax']['#relationship']) && $trigger['#relationship'] != 'none') {
+        $entity = $results_row->_relationship_entities[$trigger['#ajax']['#relationship']];
+      }
+      else {
+        $entity = $results_row->_entity;
+      }
+
+      // Reload the entity.
+      $entity_type = $entity->getEntityTypeId();
+      $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity->id());
+    }
+
+    // If the entity has the field - write the value.
+    if (isset($entity) && is_object($entity) && $entity->hasField($field)) {
+      if (in_array($value_type, ['target_id', 'date'])) {
+        $entity->set($field, [$value_type = $value]);
+      }
+      else {
+        $entity->set($field, $value);
+      }
+      $entity->save();
+      return ['#markup' => "Ok"];
+    }

and replaced with

    // Get the views ResultRow.
    $results_row = $form['output'][0]['#view']->result[$row] ?? NULL;

    // Find the entity we are updating from the ResultRow.
  if ($results_row instanceof ResultRow) {

  if (

    isset($trigger['#relationship']) &&

    !empty($trigger['#relationship']) &&

    $trigger['#relationship'] != 'none'

  ) {

    $entity = $results_row->_relationship_entities[$trigger['#relationship']];

  }

  elseif (

    isset($trigger['#ajax']['#relationship']) &&

    !empty($trigger['#ajax']['#relationship']) &&

    $trigger['#ajax']['#relationship'] != 'none'

  ) {

    $entity = $results_row->_relationship_entities[$trigger['#ajax']['#relationship']];

  }

  else {

    $entity = $results_row->_entity;

  }

      // Reload the entity.
if ($entity !== NULL && is_object($entity)) {

  // Proceed as before

  $entity_type = $entity->getEntityTypeId();

  $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity->id());
    }
} else {

  \Drupal::logger('views_entity_form_field')->error('No entity found for row @row and field @field', [

    '@row' => $row,

    '@field' => $field,

  ]);

  return ['#markup' => "Entity not found."];

}
    // If the entity has the field - write the value.
if (isset($entity) && is_object($entity) && $entity->hasField($field)) {
  $field_type = $entity->getFieldDefinition($field)->getType();

 
  if ($field_type === 'entity_reference') {

    // Entity reference (user, taxonomy, node, etc.)

    if (is_array($value) && isset($value['target_id'])) {

      $entity->set($field, [ ['target_id' => $value['target_id']] ]);

    }

    elseif (is_numeric($value)) {

      $entity->set($field, [ ['target_id' => $value] ]);

    }

    elseif (is_string($value) && preg_match('/\((\d+)\)$/', $value, $matches)) {

      $entity->set($field, [ ['target_id' => $matches[1]] ]);

    }

    else {

      \Drupal::logger('views_entity_form_field')->error('Could not extract target_id from value: @value', ['@value' => print_r($value, TRUE)]);

    }

  }
elseif ($field_type === 'datetime' || $field_type === 'timestamp') {
  if (is_string($value)) {
    $entity->set($field, ['value' => $value]);
  }
  elseif (is_array($value) && isset($value['date'])) {
    $date = $value['date'];
    $time = isset($value['time']) ? $value['time'] : '00:00:00';
    $datetime = $date . 'T' . $time;
    $entity->set($field, ['value' => $datetime]);
  }
  elseif (is_array($value) && isset($value['value'])) {
    $entity->set($field, $value);
  }
  else {
    \Drupal::logger('views_entity_form_field')->error('Unexpected date value: @value', ['@value' => print_r($value, TRUE)]);
  }
}
  else {
    $entity->set($field, $value);
  }
  $entity->save();
  return ['#markup' => "Ok"];
}

attached you can find the file. If anyone can check and create a patch i would be grateful.
EntityFormField.php_.txt

This is really the first time it works for me as expected for all tested cases like "standard text, boolean, entity reference and Date field". I have tested it several times with a multiple nodes and all works finally as expected.

🇸🇰Slovakia coaston

Well it seems this module is almost dead and there are like 70+ open issues with no admin activity and when there is anyone who can help and possible enhance this awesome module - you wont let him to help you?
Why?

🇸🇰Slovakia coaston

Hi @pcate , When I try BUILD FORM > FORM FIELD: SET LABEL - it works fine for any field, so I guess this can be closed?

However this one does not work for a submit button so there is additional issue 3511126 ECA Form: Change button label Active created.

🇸🇰Slovakia coaston

Hello,

Is there any update?

When I try BUILD FORM > FORM FIELD: SET LABEL - it works fine for any field, but not for a submit button so I guess this issue was created exactly for this.

🇸🇰Slovakia coaston

It works finally.

It seems i need to use additional event "form submit" and now "FORM:Compare Triggered Submission" works.

🇸🇰Slovakia coaston

I am lost :(...

1. Build Form (article)
2. Action FORM:ADD Submit button ie. Trigger name "abc" , label "ABC", type "Secondary"

When I navigate to article node I can see button there, if I click on it it will redirect me to "/admin/content"

How can I change that behavior so for example it will clone the current node, or display some message when I hit that button ? ...When I try to use additional action like "display message" or "Entity: Clone existing" it will clone the entity during the refresh the page no matter if I click on that submit button or not.

so what should be step 3 actually ? I believe I need to use that trigger name anywhere, but not sure where..

🇸🇰Slovakia coaston

Thank you guys, it works as expected. So the solution is very simple here.

For others with a similar problem: There is no need to use Action(task) called "entity:load via reference", but for custom_field use just direct token instead.

My profile fields:

so I was able to use direct token in ECA :
CustomFIeld: Required role is <strong>[buildstart:field_custom_pm:pm:entity:field_type_of_user]</strong>and assigned user will be: [buildstart:field_custom_pm:pm:entity:field_user_information]

and this is expected result:

Such a simple solution and I have spent like 3 days :D

🇸🇰Slovakia coaston

Thank you for your input, but unfortunately ,the same result, except instead of ref.number "3" it uses "username" when I try with "entity".

ECA Build form - Load via Reference (process_k086hog) for event eca.form.build: Field coaston does not exist for entity type node/project..\n\

🇸🇰Slovakia coaston

Thank you, just a little hint is needed - should I start with "Build Form" or "After build form" when I need to achieve "cancel" button ?

🇸🇰Slovakia coaston

First of all - My bad, I should mention that currently I am using Entity Extra field and would like to replace it and use only your "custom_field" module. That is the reason why I raised this issue.

Secondly. I am testing on clean drupal 10.5.1 latest version where currently only 2 contrib modules are installed 1.Custom_field and 2.ECA. I have also uninstalled already mentioned "Field Group" module.

I am quite surprised that you are not able to reproduce the issue because it is quite simple, but here you can find detailed step by step:

1. Create Content TYPE A (Project)
2. Create Content TYPE B (Project Inventory)
-on TYPE B - add field entity reference to Content type A

3.Create dummy Project (content type A)
4.Create dummy Inventory with ref to Project.

Create a View like "Project Inventories" of Type B.
-Add Relation ship - connect project with inventory (Ref to Project field)
-Add Title with relationship.
-Add Contextual filter - ID (with relationship and Provide default value : Content ID from URL)

Now you should be able to see view only for specific Project ID.

5- on Content TYPE A - add field > custom_field with subfield viewfield and use that currently created view (Project Inventories)

6. Now go to our first project edit it and assign that viewfield with that view
7.You should be able to see our view displayed correctly.

8.Now create new dummy project our viewfield and visit it.
9.You should be able to see at least label of our viewfield but also class in browser.

Of course in Manage display I can disable all labels so I have tried but still it tries to render anything:

With above steps this you should be able to simply reproduce the issue.
I have mentioned Entity Extra field because there was exactly the same problem and it was resolved. Now it won't display/render anything in browser!.

Another step is to install already mentioned Field group module, which uses tabs and if there is no any view rendered, the tab is hidden by default. In some cases our Projects don't have any Inventory at all so our customers would be confused what this tab means and why it is there displayed and empty. Thats why I would like to not see it if there no any inventory assigned to project.

Entity extra field basically does the same thing as your viewfield ,except it can render also blocks, but I don't use it for blocks, so I would love to uninstall it and use only your viewfield subfield as in my case it does the same.

Hope it makes sense now.

🇸🇰Slovakia coaston

Thank you!

I tested it and it works as expected :

However the Display mode formatter it seems only works for the "default". When I change to table or flipped table it does not save it. {nothing in logs}. The same "issue" when I tried with Views - only the default formatter works as shown here: Formatter.mp4

🇸🇰Slovakia coaston

Thank you.
i am in, but will be limited due to vacation time.

🇸🇰Slovakia coaston

Hi

I think you can add Custom field as an alternative module. With custom field you can add as many "reference subfields" as you like so you are not limited.

🇸🇰Slovakia coaston

Kriss, simply use ECA module - witht this one you can do anything you like and this is basiclly very simple like 20 seconds task there.

🇸🇰Slovakia coaston

Settings for whether to show timezone in form?

I guess so.

Settings to make it required if a value is set?

Well maybe add ability in form display to add default value - like UTC preselected by default? And if no default value is configured - yes required field would do the trick.

Should it be permissioned? Example: If you as admin set a timezone value, should other user ALWAYS be allowed to override it to some other value?

Well we (PMs) have backups and of course there can be a mistake so any backup or "Regional Lead" should be able to change it if needed so at least "role" based would be nice.

Settings to filter the timezone options? Maybe you want to make it simple and just have a couple relevant timezones to select from?

That would be really nice feature as currently we work in severals countries only and do not need to see list options of all timezones. So sort of "multiselect list in form display mode" would be really helpfull so we can select like 20 to show for our PMS and if needed later we can add more in settings.

Assuming we should add multiple options here for output of which timezone to display the date in. Site timezone, user timezone, new timezone value on date field?
Views stuff may need to remain the same perhaps for now at least at least for sorting, not sure how multiple values in different timezones would work?

Well smart date works in similiar way, unable to display the date in both timezones at the same time but in views you can add the same field twice (multiple times) and for every field choose diferent timezone to display - site timezone, or or user timezone and of course that selected one and also there is option to display in UTC.

Hope it helps. Much apprciated your time and effort:)

🇸🇰Slovakia coaston

My expectation was to have two fields:
1. A datetime field
2. A timezone selectioN

You would choose their timezone on save, and the actual date saved would be in their timezone, but the value shown to you would be in your timezone?

No, I want to see it always in their timezone because the change was made there, and it is their local time. I don’t care about my US time. For example, an engineer will call me to say the job is done at 9:00 PM local Berlin time, and I would like to add 9:00 PM to the system. However, currently, the system recalculates it to my profile’s timezone and stores it as 11:30 AM UTC, which is 1:30 PM in my timezone, not the reported 9:00 PM.
It would be nice to have a timezone selection that ignores my profile’s timezone. So, if I add 9:00 PM and select Berlin/Germany, it will store 7:00 PM UTC in the database.
You’re probably right—it’s better to create a new subfield type instead of modifying the default “date” type with a widget only.

🇸🇰Slovakia coaston

Thank you for your information.

I have installed switch page theme module for a temporary solution of my specific content type as it works fine with claro theme.

🇸🇰Slovakia coaston

Ah I just realized I am using Cancel button module. Once I disable it - it works as expected. So it is caused by this module. However once I disable ECA model it also works, so looks like ECA and Entity Form Cancel Button are not compatible in this case.

So not sure if anyone can help - and determine why ECA Entity Form Build Entity task has such "weird" impact.

🇸🇰Slovakia coaston

Well, to implement ability to add "optional" timezone converter using timezones or using php

print_r(DateTimeZone::listIdentifiers());

would be really nice. The same as currently module smart_date does.

so user can optionally select also timezone and it will be converted to UTC as always in database. That would be really nice feature and as you suggested if enginer is in Berlin, or in Paris, PM can select his timezone.

🇸🇰Slovakia coaston

Thank you,

I have tested your code with a custom module and I have disabled "My eca model" and now when custom module force teaser or any other view mode (including the default one" i can see title twice. So it seems you were right it is not eca related.

Not sure what now:)

🇸🇰Slovakia coaston

Hm...even I change from "teaser" to "default" view mode in "Entity:set view mode" it is the same.

Actually i wanted condition if customer is X then teaser and if negate condition use default.
-title is displayed in both cases.

But of course I have tested with a simple model where there is not any condition but if I choose "default" there is the same behaviour.

🇸🇰Slovakia coaston

Thank you, your patch works as expected. No issue found. I think it is ready to be merged.

🇸🇰Slovakia coaston

Actually #7 is my answer to your question jurgenhass.

If there is not any plan to provide a patch i think this topic can be closed as this workaround with Form:add grouping element is quite a good one.

🇸🇰Slovakia coaston

Thank you.

Well, i currently cannot update php (8.1.26) to later version due to stakeholders so I was afraid to update to 3.1 if there is not any 8.2+ php requirement. But if not i will because some modules need higher version of php already.

But back to topic - i just wanted to provide workaround for others with the same problem that ECA can update custom_field and its subdields without loosing data.

You can create one standard field and use it for feeds cvs import and then with eca connect it with custom_field and replace values so in this case data wont be lost.

Example:
I do have csv with 2 columns and 1000 rows: first column : node_id
Second column : city

City is our custom_field:city but i cannot update it using feeds because the rest 10 subdields will be replacet with value null.

So i can create a standard field called "feedimport" and it can be a string one for example. In feeds maper i will use first column node_id and the second city as source but feedimport as my field.
Will import 1000 cities to my feedimport field
Now will create views and get all nodes which dont have feedsimport field blank so i will get exactly 1000nodes i need.
Now using eca i can loop the view and replace the value from its feedsimport field to custom_field:city and right after clear feedsimport field to null so it is blank and will be ready for next use.

This looks a bit complex, but it is no coding solution and one time configuration only because that feedsimport field you can reuse for any content type just update eca with the exact custom_field:subfield next time is needed.

So i can repeat the process for my other subfields if needed. But yeah if more then 2 fields need to be updated this is time consuming.

But i will give a try and try to update your code to see if it helps for my purpose.

🇸🇰Slovakia coaston

What a pity.

For a select list with a several options is good workaround to use eca module using Views as follow:

1.Create a standard boolean field called "feedsimport" to content type
2.Use feeds module and update to value 1 all content types which needs to be updated.
3.Create view and use filter to boolean 1 so only nodes which need to be updated are selected.
4.Create eca model > Use Loop of view with "Views: Execute query" task and "Set: Field value" of your custom field(subfield) like custom_field:status with your prefered value like "Open" or "Closed"

This works fine for simple select list, but in my case like Location ,or city which is always different ECA won't help I guess :(

🇸🇰Slovakia coaston

Does it mean that entity_reference does not work currently ? Because it always fails for me :(

🇸🇰Slovakia coaston

Hi Ampsooner,

Sorry to add comment to already closed one, but struggling to add entity reference to taxonomy field I am using following code :

/**
 * Adds the "categoryref'" column to the "Settings" field
 */
function custom_field_updates_update_9037(): void {
  /** @var \Drupal\custom_field\CustomFieldUpdateManagerInterface $update_manager */
  $update_manager = Drupal::service('custom_field.update_manager');
  $update_manager->addColumn('node', 'field_settings', 'categoryref', 'entity_reference', ['target_type' => 'taxonomy_term']);
}

It always fail with the message :

custom_field_updates module
Update #9037

    Failed: Drupal\Core\Field\FieldException: Field 'categoryref' references a target entity type '' which does not exist. in Drupal\custom_field\Plugin\CustomField\FieldType\EntityReference::schema() (line 40 of /modules/contrib/custom_field/src/Plugin/CustomField/FieldType/EntityReference.php).

Any help would be appreciated.

🇸🇰Slovakia coaston

Hi killah89,
Use visible when bool field has value 1.
So unchecked or 0 will be hidden.

Or you can try option "empty", but above one works fine.

However this is different topic related to date field in modal dialog windows, so you should raise a new one if above wont work.

🇸🇰Slovakia coaston

Yeah I did, it works for all types, except the date field.

🇸🇰Slovakia coaston

Is there any update - i do like an idea to release a 2.0 branch.
Is anyone able to release a new version?

🇸🇰Slovakia coaston

It works now..yupii.

Instead of field group i used ECA directly.

Form:add grouping element and I have added element name like "datex" , title and fields just field_date so I was able to use element name "datex" as my field name of Add state.

However as Title is required i was not happy with details wrapper so I added additional "form: add container element" and element name "datex" so now everything works as expected.

However I am not sure how this "form: add container element" works.
I think I do not need both forms at the same time but currently this is my workaround.

Do you think there can be any patch created which will add container to date fields by default so no need to do such "workarounds"?

🇸🇰Slovakia coaston

thank you, it seems you are right.

I have also tested with custom_field module and it does not hide the field by default when the widget is "Stacked" however when you change it to Flaxbox and use "fieldset" or "details" type of Wrapper it works.

So I wanted to replicate the same as you suggested with the date and for me the fastest way is to use field_group module, so I added field group HTML element , with "div" element and added extra CSS class "datewrapper" and added CSS like

.datewrapper {
  padding: 10px;
  border: 1px solid #ccc;
  background-color: #f9f9f9;
}

However I can still see the date field , of course the css is applied correctly, but still not working with visibility. I have tried also with fieldset type of field group with the same result :(

Any suggestion? Any advice would be greatly appreciated.

Production build 0.71.5 2024