[development] Inserting fields into a form

Jeff Greenberg jeff at ayendesigns.com
Mon Sep 7 01:54:08 UTC 2009

I'm hooking hook_form_MY_FORM_ID_alter in order to add additional fields 
to the form. The current fields have associative keys ('name', 'mail'). 
How do I add fields between them? There isn't a PHP call to do an insert 
into the middle of an array, and while using array_splice works, it 
won't use associative keys. The numeric keys result in the form looking 
ok, but when I ask the CAPTCHA module to give me a link on the form, it 
puts it right between the first field (associative key) and the first 
that I inserted (numeric key), which I think has something to do with 
the key problem. Is there an api call I've missed to let me specify 
where to add fields, or do I have to rebuild the form array in order to 
do it?

More information about the development mailing list