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

Setting a field value from a form_alter hook

I'm trying to set a hidden field value from a form_alter hook but all these options fail.

$form['campaign'] = 'test';
$form['campaign'][LANGUAGE_NONE][0]['value']['#value'] = 'test';
$form['campaign']['widget'][0]['value']['#value'] = 'test';
$form['campaign']['value']['#value'] = 'test';

This, however, works so the Hook is OK.
$form['#action'] = 'test';

I don't know what else to try and can't find anything on this forum different from the above.

Please help!

Sum in views

In a views, I have only one content type, with a field_import. In _views_pre_render I have entered this code to calculate the sum
              foreach ($ view-> result as & $ row) {
                $ Total + = $ row -> _ entity-> get ('field_import') -> value;
              }

Probleme with multiple values using entity reference

Hello

I created a module for Drupal 7 in which I import my data through a CSV file, in a column 10 I put ids as reference values for a reference entity field as in the image below , what I need is when I upload my file I want the values to be filled automatically in the reference entity field named "field_theme"

Thanks for your help

https://postimg.cc/QFLn5Cg7

Twig creating <br> on its own [fixed/solution]

I have a tempalte file that i render like this

$image_ = [
  '#theme' => 'amazon_detail',
  '#item' => $item,
  '#detail' => $action,
  '#attached' => [
    'library' => [
      'amazon_pa/amazon_pa',
    ],
  ]

];

The problem is that twig is converting my formatting into <br> code

If i press enter to format code taht happens. If i remove all of these linebreaks it works

This twig templatecode

Dependent filter values for search criteria in D8

Hello,

I would like to create a D8 module which will display a list of a given ContentType based on a filter method. Some of the filter elements are dependent on others. For example, talking about cars, if one selects the make Honda, he expects to find within Models <Civic, Jazz, CR-V etc> but not <A1, A2, A3, A4, A6> which corresponds to Audi make.

This is the main point of my question: how to create these dependent filter elements (for example all make and dependent models for cars) ?

Thank you for your advice.

Read Webform Action gives random string

Hi

I have a webform for which I need to get the action url inside a form_alter hook.
The hook is working OK for other things.

I've tried what appears to work elsewhere $url = $form['#action']; but it's giving me this random string!

form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM

Why would that be?

Pages

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