Inline js inside a form I'm trying to attach inline js inside a form, but it's not working out. Is there anything wrong with below code

$form['#attached']['js'][] = array(
    'data' =&gt; 'jQuery(function() { console.log("test"); });',
    'type' =&gt; 'inline',
);
You seem to be trying to use method for adding settings. I believe this is the correct way as stated on the docs:

$form['#attached']['js'] = array(
  'jQuery(function() { console.log("test"); });' =&gt; array(
    'type' =&gt; 'inline',
  ),
);


Docs: #attached