1

I made a form, with a few fields. In the hook form alter I add some info text depending on the value of a $_GET variable. Only the hook alter is only called the first time. I want is to be called every time the form is viewed.

Am I using the wrong hook?

4

You need to either disable cache entirely with max-age = 0 or to make it vary based on the GET argument value, which is the better way unless your GET argument unique for everyone or most people.

Something like $form['#cache']['max-age'] = 0;

See https://www.drupal.org/developing/api/8/render/arrays/cacheability for the documentation.

| improve this answer | |
  • I added used the max-age = 0 approach and it seems to work fine now. – Johan Haest Aug 30 '16 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.