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:
----------------------
okay.cool
Thanks, that was it.
Thanks, that was it.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks
You save my day! Thank you