I would suggest altering
'#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
for Checkboxes, radios and Select lists to be
'#options' => array('1' => '1', '2' => '2', '3' => '3'),
or
'#options' => array('1' => 'one', '2' => 'two', '3' => 'three'),

This would keep the keys consistent when not manually altered. Currently a user creating 5 options would have:

  • one|Option 1
  • two|Option 2
  • three|Option 3
  • 1|Option 4
  • 2|Option 5

Alter the code above would render

  • 1|Option 1
  • 2|Option 2
  • 3|Option 3
  • 4|Option 4
  • 5|Option 5

Comments

quicksketch’s picture

Thanks, I agree this would be a good change. I've done this a number of times myself. I had intended the string values in the default to show an example of how to use keys, but it's probably not a very strong example. I'm going through the Form Builder queue today, I'll make this change shortly.

quicksketch’s picture

I also turned up #1405956: Default values of "0" for checkboxes and radios not saved, which I want to get fixed first, since changing the default keys to be something non-zero makes that problem less obvious.

jeff.k’s picture

great thanks. Awesome module by the way.

My users are not tech savvy and I was not able to use webform before I came across this module.

quicksketch’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new535 bytes
new2.09 KB

Thanks, yeah it's been a long time coming for this module to mature. I'm glad to see people using it.

I've worked this feature out so that we use the keys 1, 2, and 3, but it had the unfortunate side effect of making the next option (say you added "four" as a value) have the key of "0", then the next item would get a key of "4", making it so the whole numbering scheme was totally messed up.

This needs to be fixed as part of Options Element too then, though unfortunately I just made a release of that module yesterday (doh!) I'll put this one in after Options Element's new release has been out for a bit and make sure no new bug reports come in. Then I'll put this in at the same time as the new Form Builder release, at which time I'll make a new Options Element to match it.

quicksketch’s picture

Title: Option Keys » Set default option keys to numbers and increment intellegently
Status: Reviewed & tested by the community » Fixed

Committed to Options Element (now in the new 1.6 version) and to Form Builder.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.