Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

If your date field is not a DATETIME but a DATE, use a different format. And a better solution would be to use the Datime object constant to get the format. constant DATETIME_STORAGE_FORMAT :: string(12) "Y-m-d\TH:i:s" constant DATE_STORAGE_FORMAT :: string(5) "Y-m-d" Working example. $dtime = DateTime::createFromFormat("m/d/Y - G:i", $row->Date); // ...


-1

OK, I found the problem. In my routing file, I was missing: options: no_cache: TRUE That fixed it.


0

I was able to combine two of the responses to solve my problem. I indeed updated it to use the symfony that is now part of drupal 8. (Comment #3). Reading https://www.drupal.org/docs/7/security/safely-impersonating-another-user gave me an idea to test for anonymity. So I ended up changing the original code to: if(\Drupal::currentUser()->isAnonymous())...


2

You can get the multiple values input in a table format with the draggable option if you choose Autocomplete widget for that field under Manage form display for that Content type (not the Autocomplete (Tags style)). If your field accepts an unlimited number of values the widget will present as one autocomplete input field with a button to Add another item. ...


0

It seems Field collection/tabular data solution is what you're after. In Drupal 7 the popular module for that was Field collection. In Drupal 8 Paragraphs seems to be popular, although its description is pointing heavily to the current fad of designing content pages with separate sections, it is still a solution that allows for a more structured group of ...


0

At a high level, you could do something like this with a custom module: Create a custom VBO action (see docs) to take action on your selected nodes. Have your custom VBO action redirect to /node/add/payments with some query parameter that encodes your selected nodes (e.g. /node/add/payments?my_nids=1,2,3). Add hook_form_alter() invocation in your module to ...


1

The combination of Relationships and Contextual filters to make it work isn't random, it actually follows your requirements just as you've written them, you only need to add them to your Views configuration the way you describe. How Views types work You want a list of nodes, that is why you create a Content Views Display. Content Views display information ...


0

I have found an answer here: https://www.drupal.org/project/webform/issues/3046808 if ($source_entity = $webform_submission->getSourceEntity()) { $nid = $source_entity->id(); } else { $nid = NULL; }


1

this hook is invoked with module_invoke_all which should pass argument by value (and not by reference like drupal_alter() ) That's not how PHP works - $node is an object; objects are (ostensibly) passed by reference. Or, more accurately, from the docs One of the key-points of PHP5 OOP that is often mentioned is that "objects are passed by references by ...


0

It work for me =) $field_link_file = field_get_items('node', $node, 'field_docs_files'); $file_url = file_create_url($field_link_file[0]['uri']); $parts = pathinfo($file_url); $extension = $parts['extension']; if ($extension == 'jpg' || $extension == 'png' || $extension == 'tif') { $options = array( 'type' => 'colorbox', 'label' => 'hidden', ...


0

Make sure that the webform's source entity id can be prepopulated via a URL and the below code should work using $source_entity->id() instead of $source_entity->id /** @var \Drupal\webform\WebformRequestInterface $request_handler */ $request_handler = \Drupal::service('webform.request'); $source_entity = $request_handler->getCurrentSourceEntity('...


0

Try with the value of the field and then concatenated with " like the second way: I tested it with the following: "name" : {{ content.field_text_test.0['#context']['value'] }} <br> "name" : {{ '\"' ~ content.field_text_test.0['#context']['value'] ~ '\"' }} <br> "name" : {{ '\"' }} {{ content.field_text_test.0['#context']['value'] ~ '\"' }} {{ '\"...


0

Drupal 8 In Drupal 8, you can try using the rabbit_hole module. Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page.


0

Similar to the original posting requirements above, I required something similar, but used a Rules Link created Bootstrap Button situated on a Node page to which then redirected the Action Rule to the Message page and used the following syntax to autocomplete the Recipient field fill of both the message and the said Subject: messages/new/?edit[recipient]=[...


1

Drupal has dedicated theme hook, hook_page_attachments_alter, for this scenario. Your theme can hook into it, check the rendered route (for your node type), and take action on the $page['#attached']['library'] render array accordingly: function MYTHEME_page_attachments_alter(array &$page) { $node = \Drupal::routeMatch()->getParameter('node'); if (...


0

This is a very late answer. With \Drupal\node\NodeInterface interface, I'm using that snippet to achieve your needs : /** * Implements hook_node_presave(); * * @param \Drupal\node\NodeInterface $node */ function module_name_node_presave(\Drupal\node\NodeInterface $node) { if($node->get('field_name')->getString() != 'search') { $node-&...


0

Here is a simple method available for the same : $tid = 'Enter tid number say 5'; $nids = taxonomy_select_nodes($tid, FALSE); // count node here $count = count($nids); // you can load node content here $nodes = node_load_multiple($nids);


0

You can use {{ date }}. Just leave editing of the altered on no content type enabled. Which case is changed will be displayed in this same variable


1

Field Group is a module that provides this functionality. https://www.drupal.org/project/field_group


2

$form_state is an object, not an array. You should be able to get the values like $my_value = $form_state->getValue('custom_group'). Or get all values like $values = $form_state->getValues(). See: Introduction to Form API


1

{{ content.field_type_poi }} doesn't necessarily render the entire content of the taxonomy term. You can select the field in the tab Manage Display where you've added the field field_url to the vocabulary. If you need multiple field selections, here only this field, but in all other places the default selection, then add a custom view mode in Custom Display ...


Top 50 recent answers are included