I want to be able to build a json object that reflects the key/value pairs that a whole OO.ui.FormLayout would submit were it to be POST'd.
I would expect this object to look like {element_name: element_value, ...} for all the named elements in the form.
Since OOjs UI provides the ability to set a "data" value which is far superior to the string-only "value" attribute that is set in an HTML element, I'd like to also request to be able to prefer the value of a "data" elements when they are available.
Using it might look something like this:
var option1 = new OO.ui.ButtonOptionWidget( {data: 1, label: 'Option 1'} ); var option2 = new OO.ui.ButtonOptionWidget( {data: 2, label: 'Option 2'} ); var option = new OO.ui.ButtonSelectWidget( { name: "option", items: [ option1, option2 ] } ); var text = new OO.ui.TextInputWidget( { name: 'text' } ); var fieldset = new OO.ui.FieldsetLayout( { label: 'Some fields' } ); fieldset.addItems( [ new OO.ui.FieldLayout( option, { label: "Which option?" } ), new OO.ui.FieldLayout( text, { label: "What text?" } ) ] ); var form = new OO.ui.FormLayout( { items: [ fieldset ] } ) $( 'body' ).append( form.$element ); // Some typing and clicking happens form.getValues( { preferData: true } ) /* returns { option: 2, text: "Some text that was typed" } */