This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Import Twig Macro in Module Not Theme (Solved)

I have numerous twig templates in my module directory:

my module_name/
    src/
    templates/
      xxx.twig
      yyy.html.twig
    mymodule_name.module
....

How do I import xxx.twig inside of yyy.html.twig?

I do not want to put xxx.twig in my theme directory.

Contributed module template replacement

I have a custom module and I want to replace a template file of that in a contributed module. 

This is the template.
<!-- END OUTPUT from 'modules/contrib/hg_reader/templates/node--hg-event--teaser.html.twig' -->

Form ID of Views Exposed Filters

Why is the form id of an exposed views filter always "views_exposed_form"? I have several exposed filters among my views. How am I going to tell the difference between them in hook_form_alter?

Form API drupal vs custom js validation

My question is more to get a better understanding about this Drupal form, not as much the specifics here. I cleaned it up a bit. I'm trying to figure out what is allowing this form to use the Drupal validation and can I replace it with custom ajax to validate field by field, so it displays the error text below each field rather than how it is now in one error block. Is it necessary to disable the built in validation or just override? So instead of "setMessage" can this be done with callbacks on each field?

<?php

namespace Drupal\make_form\Form;

Update list field in callBack

I have a "Movements" content type with various fields, two of these are entity references the first "field_richiedente" connected to the "Applicants" content type and the second "field_activity" connected to the Activity content type
The "Applicants" content type has a multivalued entity reference field, linked to the "Activities" content type, where you can enter the various activities that the applicant can carry out

Automatic filter in views

In a views I have a filter with a title field in which I display the date of the day. If I click on the filter button it filters me by date.
I didn't understand how to automatically filter as soon as the views are displayed

case 'views-exposed-form-gestione-sedute-page-1' ;
    $form['title']['#attributes']['placeholder'] = 'gg/mm/aaaa' ;
    $form['title']['#attributes']['value'] = date('d/m/Y') ;

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions