New answers tagged

-1 votes

I cannot install Geocoder

You can also try re-running composer require with an explicit version constraint, e.g. "composer require drupal/geocoder:*" to figure out if any version is installable, or "composer ...
hetal chavda's user avatar
0 votes

Adding a default text

Never tried with that dependency but option 2 should work, how are you setting the conditional field? Anyway there's empty fields module that should solve your issue.
Giuseppe's user avatar
  • 897
1 vote

Adding a default text

Solution for option-1 : {% if node.field_example.value is empty %} <span>Bye</span> {% endif %}
hetal chavda's user avatar
0 votes
Accepted

How do I take the value of a variable from the node template and insert it into the field value?

The correct answer in my case is either to write your own module with your own logic, which will substitute the necessary values into the fields through hooks: hook_entity_presave() - will add when ...
Владимир Помелов's user avatar
0 votes

Form with two submission buttons

#submit: Specifies an alternate callback for form submission when the submit button is pressed. Use '::methodName' format or an array containing the object and method name (for example, [ $this, '...
Kedar Khaire's user avatar
3 votes
Accepted

I am trying to install Drupal Commerce, I get error that prevents installation, I don't get what it says about ../private folder

The private files directory is a standard Drupal setup task, and is well-documented. Below is its description in default.settings.php. It is in settings.php where you configure this directory. Not ...
cilefen's user avatar
  • 5,557
-2 votes

How can I programmatically save node components?

$entity = \Drupal::entityTypeManager()->getStorage('cohesion_layout')->load($node->get('field_layout_canvas')->getValue()[0]['target_id']); $layoutCanvas = $entity->...
Pratik Kadambari's user avatar
0 votes

How to set widget for a field on a custom form?

I encountered a similar challenge, and after some experimentation, I found a solution that works well for my specific case. public function blockForm($form, FormStateInterface $form_state): array { ...
edykst's user avatar
  • 1
0 votes
Accepted

How can I have updated content entity data immediately available after update?

I solved my problem indirectly. My code to create the content entities was using Database API, mainly $database->merge('entity') ->insertFields($insertFields) ->updateFields($...
gbmapo's user avatar
  • 1,066
0 votes

Edit index config (Search API) programmatically and get the status index updated

To reindex items as it's done through the UI, you can do the following (but this won't queue the action so it can be super slow and you should avoid calling it inside a controller action for example): ...
Robin's user avatar
  • 163
0 votes

How to make media description show on form view when used as entity reference

I had this same issue and found the solution: If you want to be able to add a new file with a description using Media library then visit /admin/structure/media/manage/document/form-display/...
fallenturtle's user avatar
1 vote

How can I have updated content entity data immediately available after update?

This is generic code that use to invalidate tags: use Drupal\Core\Cache\Cache; Cache::invalidateTags($node->getCacheTags()); Note: where $node denotes entity object whose tags needs to invalidate ...
mini's user avatar
  • 682
2 votes

How can I have updated content entity data immediately available after update?

It could be the way you reference the custom entity. If users reference the custom entity, the render cache will be invalidated when updating the references. If you reference backward, from the custom ...
4uk4's user avatar
  • 98.1k
0 votes
Accepted

Why is my message not showing for anonymous user?

It was drupal_flush_all_caches() that was the reason of message not showing. Once removed, everything works as expected.
gbmapo's user avatar
  • 1,066

Top 50 recent answers are included