Customising the submitted field name

Mar 7, 2012 at 6:13 AM

Hi, 

I've got a suggested tweak to allow customisation of the submitted field name. 
By default, this is the same as the id of the div you're decorating but this doesn't work so well for Ruby/Rails as this framework uses fieldnames like this:

object[fieldName]

So I made a couple of tweaks to my jquery.flexbox.js file:

from line 59:

var $hdn = $('<input type="hidden"/>')
            .attr('id', $div.attr('id') + '_hidden')
            .attr('name', o.fieldName ? o.fieldName : $div.attr('id'))
            .val(o.initialValue)
            .appendTo($div);

 from line 837:

initialValue: '', // what should the value of the input field be when the form is loaded?
fieldName: '', // specify submitted for field name - will default to id
watermark: '', // text that appears when flexbox is loaded, if no initialValue is specified.  style with css class '.ffb-input.watermark'bmitted for field name - will default to id


You can then use the option like this:

 $(function() {
     $("#venue").flexbox('/races/venues.json',{
         displayValue: 'venue',
         hiddenValue: 'venue',
         initialValue: '<%= @race.venue %>',
         resultTemplate: '{venue}',
         fieldName: 'race[venue]'

     });
   });

Would love to see this or a similar change make it into the release...