Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Jaypan on
I'm trying to use the new form api attribute #attached to attach some javascript settings. The settings look like this:
$js_settings = array('adminNotification' => array('email' => $current_email));
This is the code I've tried (along with other variations):
$form['notification_email'] = array
(
'#type' => 'textfield',
'#title' => t('Email'),
'#attached' => array
(
'js' => array
(
$js_settings => 'setting',
$js_path => $js_options,
),
),
);
I've also tried this:
$form['notification_email'] = array
(
'#type' => 'textfield',
'#title' => t('Email'),
'#attached' => array
(
'js' => array
(
'setting' => $js_settings,
$js_path => $js_options,
),
),
);
However, the setting doesn't seem to be properly attached. I'm suspecting that settings are not supposed to be attached, only files, inline js and external js, but I'm not finding any documentation to indicate this one way or another. Does anybody have any idea if my suspicion is correct?
Comments
This might help
Try:
----------------------
forward-media.de
Thanks, that was it.
Thanks, that was it.
Thanks
You save my day! Thank you