Download & Extend

Set default option keys to numbers and increment intellegently

Project:Form Builder
Version:6.x-0.9
Component:Webform Itegration
Category:feature request
Priority:minor
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

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.

#2

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.

#3

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.

#4

Status:active» reviewed & tested by the community

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.

AttachmentSize
form_builder_default_keys.patch 2.09 KB
options_element_next_key.patch 535 bytes

#5

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.

#6

Status:fixed» closed (fixed)

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

nobody click here