0

After I clear all caches I can see my update is effective in the Create Article form. Great.

But as soon as I refresh the page, or come to it afresh to create another Article, the unmodified value of #file_upload_title re-appears.

This is what I added to template.php:

function seven_form_article_node_form_alter(&$form, &$form_state, $form_id) {
    $form['field_photo_gallery']['und']['#file_upload_title'] = 'Add a new file or multiiple files';
}
3
  • try clearing your browser cache, or try it on a different browser to see if the problem persists
    – Geoff
    May 9, 2015 at 21:32
  • your using seven as theme ? otherwise adapt the hook to YOUR_THEME_NAME_form_article_node_form_alter
    – rémy
    May 9, 2015 at 22:35
  • Hmmm. Thanks for trying to help. But "... I can see my update is effective ..." so clearly the function is named correctly even though I might have chosen hook_form_BASE_FORM_ID_alter() instead of hook_form_FORM_ID_alter() - I will investigate further. As stated, all works as expected immediately Drupal caches are cleared (NB not using APC server side cache either); but, yes, both Mozilla (Firefox) and Webkit (Safari and Chrome) browsers behave the same even after client side browser cache emptied.
    – iainH
    May 9, 2015 at 22:58

1 Answer 1

0

The function seven_form_article_node_form_alterwas correctly named but not placed in the correct file in the correct folder.

The function seven_form_article_node_form_alter has to go in template.php in a (sub)theme of the administration theme seven - of course - and not in the template.php of my "front-end" theme.

The fact that I had a function in there with a prefix other than my from-end theme's should have signalled my mistake.

What mislead me was a quirk of Drupal cache clear. It happens that clearing the Drupal cache actually (and incorrectly) caused my form alterations to be displayed as my function must have been the last one in the chain to have taken effect. It was only after a subsequent page build / refresh that the form alter's effects (correctly) disappeared. So this is a quirk of Drupal cache clear that needs to be taken account of in this edge case.

Consequently I have created an administration sub theme into whose template.php file the function now sits (Does it count as one line of code or two? ;-). All is now working as it should.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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