New answers tagged 9
-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 ...
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.
1
vote
Adding a default text
Solution for option-1 :
{% if node.field_example.value is empty %}
<span>Bye</span>
{% endif %}
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 ...
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, '...
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 ...
-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->...
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 {
...
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($...
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):
...
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/...
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
...
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 ...
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.
Top 50 recent answers are included
Related Tags
9 × 1754views × 210
forms × 143
entities × 132
theming × 122
nodes × 98
webforms × 69
commerce × 66
migrations × 62
media × 54
ajax × 52
blocks × 49
composer × 48
paragraphs × 47
taxonomy-terms × 44
hooks × 43
drush × 40
database × 39
search × 38
javascript × 37
files × 37
configuration × 37
users × 35
caching × 32
i18n-l10n × 30