I'm writing a custom module and I am trying to create an array of form fields, but it doesn't seem it is what I am doing.
Here's the code I'm trying to use:
for($i = 0; $i < 3; $i++) {
$form['contact'][$i]['value'] = array(
'#type' => 'textfield',
'#title' => 'Contact Name',
'#size' => 50,
);
}
Doing this, I was expecting the form to print the field as:
<input type="text" value="" size="50" name="contact[0][value]" />
<input type="text" value="" size="50" name="contact[1][value]" />
<input type="text" value="" size="50" name="contact[2][value]" />
Instead, it outputs:
<input type="text" value="" size="50" name="0" />
<input type="text" value="" size="50" name="1" />
<input type="text" value="" size="50" name="2" />