This project has moved. For the latest updates, please go here.

Using GetValue() with a customized form field table cell

May 12, 2014 at 7:35 PM
Hi,

I have a standard out of the box form that uses jQuery to prepend a span element to each table cell on the form that contains a SP choice field (radio buttons) when the page loads. I do this so that [descriptional] text appears above each field, instead of below each field (like the default field description text does).

I noticed that when I use GetSPField.GetValue() or GetSPFieldByInternalName.GetValue() to get the values from these [choice] fields, that the value always comes back as null. However, if I don't prepend the span, the value is successfully returned. Is this possibly because the SPUtility.js code is grabbing the first child within the form field's table cell?
Coordinator
May 13, 2014 at 1:19 AM
Edited May 13, 2014 at 1:19 AM
lostdreamz,
You are correct, it uses the first child span as the "Controls" property in most of the fields.

Line 405 in https://github.com/kitmenke/sputility/blob/master/src/sputility.js:
this.Controls = $(fieldParams.controlsCell).children()[0];

I think if you let SPUtility load first, call GetSPField or GetSPFieldByInternalName to get a reference to the field, and then add the span element to each table cell then everything should work ok.
Thanks,
Kit