What I’m trying to do is add an id to a hidden field, so that I can edit its value via JS. For example, I want to give the hidden element I create via a Drupal form with this:
$form['position'] = array(
'#type' => 'hidden',
'#default_value' => '57.149953,-2.104053',
);
Which outputs:
<input type="hidden" name="position" value="57.149953,-2.104053" />
Well I would like to add an id, a name and a class to that input. What’s the best way to go around doing this?
Thanks
You can set attributes on a form element
like this: