Hi

I am trying to get a form repeat feature working with Drupal (JSTools). To make this work I need to be able to output fieldset names in an array format as follows:

name="edit[location_highlights][][description]"
name="edit[location_highlights][][distance]"

location_highlights is a fieldset form class.
description and distance are input fields.

Is there any way to do this through the forms api? I have been through the api reference, google and drupal.org but cannot find any reference to this requirement!

ps - Is drupaldoc.org down (04 June 2006) or is it me?

Thanks
Dave

Comments

robertdouglass’s picture

_-dave-_’s picture

Ok, managed to fix it although not the most elegent solution...

Changed the line (about 262) in wforms.js from:

var value = attribute.nodeValue + idSuffix;

to:

if (attribute.nodeName.toLowerCase() == "name") {
  var value = attribute.nodeValue.replace("[0]", ["+parseInt(counterField.value+1)+"]")
} else {
  var value = attribute.nodeValue + idSuffix;
} 

Updates any array decleration in the name attribute with the current row count.

NB: This change was made in the verbose version of wforms.

Thanks
Dave