Drupal 8 YAML Form Module: How do I change the value of a Hidden element?

A. Pérez

A few days ago I asked a question about Drupal 8 YAML Form Module: Populate Select Element. I found a solution that it works fine for me.

But now I've got a new doubt. I would like to change the value of a Hidden element and depending of this value, to show some elements in the form or not. I'm trying to implement the hook hook_yamlform_element_info_alter(array &$elements) and I do $elements['hidden_element_name']['#value'] = 'New value of the hidden element' but it doesn't work.

Any ideas? Thanks in advance!

A. Pérez

Here is the solution: How do I change the value of a Hidden element?

Basically, I've implemented hook_form_FORM_ID_alter() and I do:

$form['elements']['hidden_element_name']['#value'] = 'New value of the hidden element';

I hope it helps someone!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to change option name in Drupal 8 form element?

From Dev

Drupal 8: How do I customize a form widget to show an entity field value instead of the entity title?

From Dev

How do I set an form input element to hidden?

From Dev

How do I insert a cookie data value into a hidden form field?

From Dev

How do I insert a cookie data value into a hidden form field?

From Dev

Manipulate form element in Drupal 8

From Dev

How do I hide an HTML element before the page loads in conditional fields drupal module?

From Dev

How do I check if the current password that the user gives in the password reset form matches with the hashed password in Drupal 8

From Java

How do I check if an element is hidden in jQuery?

From Dev

How to pass a value from javascript to drupal 8 form?

From Dev

Using xmlstarlet, how do I change the value of an element

From Dev

How do I change element value based on the data attribute?

From Dev

How to add entity reference as a form field drupal 8? I it possible?

From Dev

How can I get the Register form on the front page in Drupal 8?

From Dev

How to change the value of hidden form data when a radio button is selected?

From Dev

How do I update a drupal module without deleting it first?

From Dev

Drupal 7: how do I save module settings?

From Dev

How can I change the title of front-page in Drupal 8?

From Dev

How can I change the title of front-page in Drupal 8?

From Dev

How to change value of appended select element in a form

From Dev

I have a row from a html table in the form : $(row).text(). How do I feed this into a input type="hidden" element

From Dev

How do I get the parent tid of a taxonomy term in Drupal 8

From Dev

How to create an advanced search form using the Drupal 8 Solr Search module?

From Dev

Change hidden value and submit form with onclick for href

From Dev

Using jQuery, how do I change the input element's value when I click outside of the input box?

From Dev

How do I change the contact form margin

From Dev

How do I change form data on submit?

From Dev

How do I change the contact form margin

From Dev

How do you create a Drupal Form Module which connects to an external Database

Related Related

  1. 1

    How to change option name in Drupal 8 form element?

  2. 2

    Drupal 8: How do I customize a form widget to show an entity field value instead of the entity title?

  3. 3

    How do I set an form input element to hidden?

  4. 4

    How do I insert a cookie data value into a hidden form field?

  5. 5

    How do I insert a cookie data value into a hidden form field?

  6. 6

    Manipulate form element in Drupal 8

  7. 7

    How do I hide an HTML element before the page loads in conditional fields drupal module?

  8. 8

    How do I check if the current password that the user gives in the password reset form matches with the hashed password in Drupal 8

  9. 9

    How do I check if an element is hidden in jQuery?

  10. 10

    How to pass a value from javascript to drupal 8 form?

  11. 11

    Using xmlstarlet, how do I change the value of an element

  12. 12

    How do I change element value based on the data attribute?

  13. 13

    How to add entity reference as a form field drupal 8? I it possible?

  14. 14

    How can I get the Register form on the front page in Drupal 8?

  15. 15

    How to change the value of hidden form data when a radio button is selected?

  16. 16

    How do I update a drupal module without deleting it first?

  17. 17

    Drupal 7: how do I save module settings?

  18. 18

    How can I change the title of front-page in Drupal 8?

  19. 19

    How can I change the title of front-page in Drupal 8?

  20. 20

    How to change value of appended select element in a form

  21. 21

    I have a row from a html table in the form : $(row).text(). How do I feed this into a input type="hidden" element

  22. 22

    How do I get the parent tid of a taxonomy term in Drupal 8

  23. 23

    How to create an advanced search form using the Drupal 8 Solr Search module?

  24. 24

    Change hidden value and submit form with onclick for href

  25. 25

    Using jQuery, how do I change the input element's value when I click outside of the input box?

  26. 26

    How do I change the contact form margin

  27. 27

    How do I change form data on submit?

  28. 28

    How do I change the contact form margin

  29. 29

    How do you create a Drupal Form Module which connects to an external Database

HotTag

Archive