What are the config options for skuid.ui.Field() constructor?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
What can I configure, aside from:


{<br>
&nbsp; &nbsp; &nbsp; &nbsp; fieldId: 'MailingCity',<br>
&nbsp; &nbsp; &nbsp; &nbsp; register: true<br>
&nbsp; &nbsp; }<br>
as shown in the docs.

Can I set all the parameters for a basic field editor (unique id, layout, mode, etc.)?  Or are those options in an skuid.ui.Editor()? The only option I see in the Editor docs is show save/cancel.


Thanks!
Photo of Matt Sones

Matt Sones, Champion

  • 31,530 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,262 Points 20k badge 2x thumb
You can use this to set Field-level options, not Field-Editor level options. Since we don't have these specific properties documented, I won't describe in more detail here unless you have a specific need. 

The way to set parameters for a Field Editor through JavaScript would be through the XML properties on the <basicfieldeditor/> tag.
Photo of Matt Sones

Matt Sones, Champion

  • 31,530 Points 20k badge 2x thumb
If I have a field editor with one field created with the skuid component factory, and I want to be able to change the mode of the field between edit and readonly with javascript, is there a preference between doing that at the editor level or the field level?

For the former, I'm assuming I could .attr("mode", "edit") with a jQuery selector on the editor?
And the latter, .attr("readonly", "false") with a selector on the field?

Is there a better way?

Thanks!
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,262 Points 20k badge 2x thumb
You could do it at either level, I think that it's more scalable to do it at the Field Editor level because then you don't have to worry about adding fields later.

The following Snippet will find a particular Field Editor by its Unique Id (e.g. here "TestFieldEditor") and toggle it between Read / Edit mode. If you want a button that only sets it to Edit mode, you can easily adapt the code to do that:

var fieldEditor = skuid.$('#TestFieldEditor').data('object');
fieldEditor.mode = fieldEditor.mode === "edit" ? "read" : "edit";
fieldEditor.list.render({ doNotCache: true });
Photo of Matt Sones

Matt Sones, Champion

  • 31,530 Points 20k badge 2x thumb
Sweet. Thanks, Zach!