Stack Exchange Network

Stack Exchange network consists of 174 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

Try to add the ID in an array format like below: $form['table'] = [ '#type' => 'table', '#header' => $header_table, '#rows' => $rows, '#attributes'=>['id' => ['IdforRow'][, '#empty' => t('No Data found'), '#prefix' => '<b>Total Tenders : '.@$count.'</b><br>', '#suffix' => '', ];


0

Found this after 5 seconds of googling: https://www.drupal.org/project/color_field https://www.drupal.org/project/colorfield https://www.drupal.org/project/jquery_colorpicker The search query was: drupal color field. Choose one, add one color field per content type to the user entity type, then retrieve the selected value and add it as body class or node ...


1

Some of those php extensions (like php-curl) were included in the core php package for arch so maybe you just need to update php? Some, (Like php-mcrypt) are depreciated and have been removed from newer versions of php (php7.2+ iirc) what version of php are you using for drupal? You may have to set an earlier version of PHP for your Drupal and then ...


0

You can load the node and then fetch the paragraph targetid . Later you can load paragraph targetid and then get all attributes of the image. use Drupal\paragraphs\Entity\Paragraph; use Drupal\node\Entity\Node; $node = Node::load($nid); $paragraph_field = $node->get("field_paragraph")->getValue(); $paragraph = Paragraph::load($paragraph_field[0]['...


0

You can use preprocess field hook which is supported in drupal 8 also . Example below: function example_preprocess_field(&$variables) { if (($variables['element']['#field_name'] == 'example')) { //get the value of the field dsm($variables); foreach($variables['items'] as $key => $item){ $vars['items'][ $key ]['#item']['...


0

I found a solution for above. I can add a field in the filter criteria selecting the URI. And expose that filter to the user with a grouped filter. In the grouped filter I can define my own keys and parameters with an operator. That worked pretty well.


0

If it is correct, should I also include print media queries in the print.css file? It's correct, and there's no need for media queries in the CSS file. (Separately, I'm still trying to determine what else is supplying the print styles in my site, aside from the ones I'm adding intentionally. But I can confirm that the above annotation example works.)


2

Typically, I found the answer 10 minutes after posting! For anyone else, in your custom submit handler get the form object from the form state. $formObj = $formState->getFormObject(); You can then call submitForm() on the form object and pass the form and form state variables. $formObj->submitForm($form, $formState); Then finally just simply ...


1

You may work with this approach. The following code snippet for drupal 7. Create field C of type number. Hide the field C in add/edit content type form. /** * Implements hook_form_alter(). */ function yourModule_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'CONTENT_TYPE_NAME_node_form'){ $form['field_c']['#...


0

Add a column for 'processed'. Each time you run the batch process select rows with a limit of 100 unprocessed rows for you batch process and then mark each row as processed. You could run this on cron or something or run a nested batch.


1

That information isn't stored against the file entity, its on the image field attached to your source entity (e.g. your node) So you could do something like: $node->my_image_field->alt $node->my_image_field->title and that would give you the alt/title


0

This can simply be overridden from your settings.php or settings.local.php. $config['language.negotiation']['url']['domains']['en'] = 'www.example.test'; $config['language.negotiation']['url']['domains']['de'] = 'de.example.test'; $config['language.negotiation']['url']['domains']['fr'] = 'fr.example.test'; Which means, that you need to set them manually in ...


0

Check the composer.json in drupal core, I think you have an old composer.json setting, here composer.json drupal 8.6.7 : { "name": "drupal/drupal", "description": "Drupal is an open source content management platform powering millions of websites and applications.", "type": "project", "license": "GPL-2.0-or-later", "require": { "...


1

Found it in $context['form']['#parents']. This is an array that contains the keys of the parent widget. In my case it looked like [ 0 => 'field_pagebuilder', 1 => ___PARENT_INDEX___, 2 => 'subform', ] which allowed me to generate my CSS selector for the states API: $deltaParent = $context['form']['#parents'][1];


0

Another option is to use a custom "Views" page that allows to filter with any taxonomy terms combined with depth. Then create a path alias for each filtered page to hide the arguments.


-2

Use the below code as a post request { "type":[{"target_id":"article"}], "title":[{"value":"Hello World"}], "body":[{"value":"How are you?"}] }


0

I could translate the group node by enable "group" and "group content" in /admin/config/regional/content-language


0

Best way to get node URL from node object- Absolute Path : $node->toUrl()->setAbsolute()->toString(); Relative Path : $node->toUrl()->toString(); It will also handle node language.


1

First of all try to take a look at the buildForm method in the UserPasswordResetForm class, it takes some parameters. So you must call getForm like this: \Drupal::formBuilder()->getForm('Drupal\user\Form\UserPasswordResetForm::class', $user, $expiration_date, $timestamp, $hash); This is the function docs, $user = User requesting reset. $...


0

You should extend EntityViewsData and you'll have the integration of your entity. Example: use Drupal\views\EntityViewsData; class CustomEntityViewsData extends EntityViewsData { public function getViewsData() { $data = parent::getViewsData(); return $data; } }


1

You can use hook_ENTITY_TYPE_presave to do this, just call if (!$entity->getSubject()) { $entity->setSubject(''); } if it isn’t filled. Hope it makes sense.


3

Categories or Paragraphs are just references when you create a node view. Thus when you use them in the fields (as output) they are not sortable but you can add a relationship to them and then their individual fields (like name, id etc) become sortable Here is an example with tags (on article content type) Added term relationship Taxonomy terms on node ...


0

I can see 2 ways to achieve it programmatically. Using Hooks. Using the Events system. 1) You can use "hook_ENTITY_TYPE_insert" in your module file. In this function/hook, you can trigger mail. 2) I believe using event system will be a better approach instead of using hooks. Currently, Drupal core doesn't provide any Events for entity(node) transactions ...


0

The example of @Ajay was not working for me. This one do. Hope this help. public function buildForm(array $form, FormStateInterface $form_state) { // Your $form fields here ... $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', '#value' => $this->t('Save'), '#button_type' ...


0

Views paging isn't conditional, so you can't assign different filters and other settings to different sets of result items. But you can achieve what you want by creating different Views displays, each with its own filter settings, then display them one below the other on a page, style the output so it looks like it's coming from the same source. If you ...


0

Thanks to @Jdrupal I finally found the solution in this link. body: plugin: iterator source: body process: value: value format: plugin: default_value default_value: basic_html (sorry I can't seem to get the mention appropriately formatted)


1

Forms have a validate and submit function(s). Submit never runs unless all validation passes. So all you have to do is add a custom validation /* * Implements hook_form_FORM_ID_alter */ function mymodule_form_user_register_form_alter(&$form, FormStateInterface $form_state) { $form['#validate'][] = 'mymodule_registration_validate'; } /* * Custom ...


0

Sorry to disagree with your own (accepted) answer, but just in case you want to consider your solution described in your answer: This seems like a perfect usecase for the Group module. Check it out, do some homework (experiments) with it, browse some of the group question. Or checkout some of these questions. For sure you'll understand what I mean. After ...


0

I was able to accomplish this using Permissions By Term (https://www.drupal.org/project/permissions_by_term). After I installed, I completed the following steps: define member/student/guest roles in People > Roles define Taxonomy structure (I named the vocabulary 'Page View Permissions') In order to apply these permissions to Basic Pages, edit the Content ...


0

The templates directory must always be a direct descendent of the module or theme root directory, in your case /modules/custom/lrg_osm/templates/ (not modules/custom/lrg_osm/src/templates/).


0

I had the same issue and I managed to solve it by finding the following issue/patch: https://www.drupal.org/project/page_manager/issues/2921404#comment-12526453


1

In a preprocess hook (preferred): /** * Implements hook_preprocess_HOOK() for page.html.twig. */ function MYTHEME_preprocess_page(&$variables) { if (isset($variables['node'])) { $variables['image'] = $variables['node']->get('field_image')->first()->view('full'); } } Or in Twig: {{ node.field_image.0|view('full') }} To use |view ...


0

As it mention in comment just use paragraph instead of node. $fieldDefinition = \Drupal::entityManager()->getFieldDefinitions('paragraph', 'your_paragraph_type_name'); foreach ($fieldDefinition as $field_name => $field_definition) { if ($field_definition->getType() == 'image'){ $settings = $field_definition->getSettings(); ...


0

What database is it? MySQL? If so, log in to the database and use the MySQL command ALTER TABLE. ALTER TABLE tablename MODIFY columnname VARCHAR(100);


0

I found by myself my mistake. The menu items are always shown for super user. The menu items are hidden/shown correctly for others users.


0

Okay turns out it was xdebug. I had to allow more simultaneous connections in the PHP Debug settings of PHP Storm.


0

The logout is probably losing the user's session with the $form_state A very simple solution is to redirect the form to /user/logout?destination=REDIRCT_PATH.


0

A solution to append a default value to the field after callback but with option for user to change input: add the value to field attributes: '#attributes' => array('value' => array($form_state->getValue('option2'))), $o = []; $form['option1'] = array( '#type' => 'select', '#size' => 1, '#options' => ['a' => '...


1

As with most things, I suggested testing it out on a development/test site before trying on the live site. It's likely that the specific set of contribs and the libraries they use will affect the success of this operation. How did you install the modules? Do you use a composer workflow? In general, some paths stored in different places are going to be ...


0

I would just go with this module: Try this module: https://www.drupal.org/project/revision_log_default


2

Your question appears to be somehow related to this issue, which is closed and fixed. That issue contains an image which looks like so: So check if the version of the Group module that you're using, includes the patch included in that issue. If you don't have it included, it's probably why you don't have a "group content type" translation option in /admin/...


0

Off the top of my head... For multiple value fields you either render out the paragraph field itself: {{ content.field_paragraph_field_name }} and let Drupal handle the multiple value rendering, or do your own loop: {% for item in content.field_paragraph_field_name %} {{ item.your.array.keys.here.value }} {% endfor %} Try: {% for item in content....


2

One approach is to add page templates to your theme registry: function MYMODULE_theme_suggestions_page_alter(array &$suggestions, array $variables) { //Allow theming the site error pages $route_name = \Drupal::routeMatch()->getRouteName(); switch ($route_name) { case 'system.401': // Unauthorized Access. $error = 401; break; ...


0

Try with: To get Uri: {{ node.field_responsive_hero_image.0.entity.uri.value }} To get Url: {{ file_url(node.field_responsive_hero_image.0.entity.uri.value) }}


-1

Add code below: class MYCUSTOMBLOCK extends BlockBase { public function build() { return array( '#markup' => '', // the content of your block ); } public function getCacheMaxAge() { return 0; // No caching gets applied here } }


0

drush status tells me that I have version 5.10.0, so that's likely the issue. D8 support was not added until drush 8. Now I need to get upgraded.


0

This is the link which you can follow => https://docs.drupalcommerce.org/commerce2/developer-guide/orders/customize-order-receipt-emails Another solution is to copy the default twig from => commerce/modules/order/templates/commerce-order-receipt.html.twig and then placed into root theme folder of your Drupal 8 project => your_project_name/themes/...


0

I was thoroughly mistaken about the installation of the charts. After installation, I was editing the repositories section in composer.json and running the composer command to install the specific library (eg: composer require --prefer-dist highcharts/highcharts:6.0.4) from the particular sub-module. But it has to be done from the Drupal project root ...


0

/** * Implements hook_form_alter(). */ function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) { switch ($form_id) { case 'taxonomy_term_application_category_form': // Hide the Button Text as its value is autopopulated from the term name. if (isset($form['field_test_para']['widget'][0]['subform']['...


0

This may be an old issue, but here's my take. Let's say you need this for node add article. <?php use Drupal\Core\Form\FormStateInterface; use Drupal\node\NodeInterface; function MYMODULE_form_node_article_form_alter(&$form, FormStateInterface $form_state, $form_id) { // Hide title field to avoid confusion $form['title']['#access'] = ...


Top 50 recent answers are included