New answers tagged

0

The second argument to watchdog must be a string. You've passed either an array or an object.


0

Here's the answer I was helped with. function MODULENAME_form_user_form_alter(&$form, $form_state, $form_id) { if (!\Drupal::currentUser()->hasPermission('administer users')) { $form['field_organization_name']['widget'][0]['value']['#attributes']['disabled'] = 'disabled'; $form['field_organization_reference']['widget'][0]['...


0

Try: function MYMODULE_form_user_form_alter(&$form, $form_state, $form_id) { // Your code... } Inspecting element, I see the form id is user-form, which needs to be translated to the machine-readable name user_form Otherwise, you can always do a standard HOOK_form_alter(): function MYMODULE_form_alter(&$form, $form_state, $form_id) { if ($...


0

FOR DRUPAL 8 modules/custom/mymodule/mymodule.services.yml services: mymodule.subscriber: class: Drupal\mymodule\EventSubscriber\MyModuleEventsSubscriber tags: - {name: event_subscriber} modules/custom/mymodule/src/EventSubscriber/MyModuleEventsSubscriber.php namespace Drupal\mymodule\EventSubscriber; use Drupal\feeds\Event\...


0

I had the same issue, but i was using {{ dump() }} to debug the template The problem I have the same arguments when i am using {{ dump() }} inside macro tags. For example: {% macro menu_links(items, attributes, menu_level ) %} {{ dump() }} ... code ... {% endmacro %} If you focus on function menu_links(), you realize that variables ...


0

Paragraphs or Field Collection doesn't matter for your code. You need to add the newly created items to a field. For example if the field collection field is in a node: $node->field_collection_name[] = $new_item; Not in a form alter hook, but in an entity create hook. See the linked question.


2

The easiest way would be to execute the View again in the page preprocess hook. If you want to avoid executing the View twice the task is getting a bit more tricky. This is because in D8 page elements are not necessarily rendered downstream in the order you expect. The element could have been cached in a previous request or in case the element doesn't ...


1

Views::getView is just a shortcut to loading the entity via the usual methods - it doesn't execute the View, so you won't see any results with the object you have. I'm not sure there's an elegant way to do what you need (although I hope I'm wrong, it seems like there would be). One simple-ish workaround would be to hook into the View's build process after ...


0

i've sorted it you can do it like this $variables['url']->getUri()


1

The only way I can think to do this is to override the entity's storage handler in hook_entity_type_alter() with a storage handler that provides the delete functionality you want. Something like // You're going to want to be sure you're extending the entity's original // storage handler. class CustomStorageHandler extends EntityStorageBase { /* * {@...


0

You can try use Content Entity Field definitions Sample code: foreach ($entity->getFieldDefinitions() as $field => $definition) { $entity->get($field)->getValue() }


0

Field format display options are components of view modes, stored in the config entity EntityViewDisplay. For example, load the default view mode for the user and extract the configured image style of the user_picture field: use Drupal\Core\Entity\Entity\EntityViewDisplay; $component = EntityViewDisplay::load('user.user.default')->getComponent('...


0

There are probably a few different ways to get that info, but if the returned format suits your needs then EntityInterface::toArray(), which Gets an array of all property values, is probably the most succinct: $field_data = $entity->toArray();


0

In my case the below code worked perfectly in Drupal 8: $form['field_idea_department']['widget'][0]['value']['#default_value'] = "default values";


0

You can't xdebug in hook itself, you need to go to method calling this hooks which is in class ViewsData path /core/modules/views/src/ViewsData.php and put breakpoint in getData, clear cache and you will get what you need.


Top 50 recent answers are included