custom field renderer to make a field required

The use case is this…

I want to have several fields on the page and then unhide them and/or make them required based on some criteria(based on the type I’m in another object defining whether the field is required and/or visible).

I need help trying to set a field as required on a custom renderer.  I am able to set it’s mode dynamically but not the required attribute.

var $ = skuid.$, field=arguments[0], value=arguments[1];

console.log('value: ’ + value);
console.log('field: ’ + field.required);

field.mode = ‘edit’;
field.required = ‘true’;
//also want to unhide this field


console.log('value: ’ + value);
console.log('field: ’ + field.required);


I think you can get what you want declaratively in Skuid. Add your field and make it required. Set your render to condition to hide it. When it is shown, it will be required for entry. If it is hidden, it won’t affect saving your record.

Here is a new Contact page that demonstrates this. When Lead Source is set to ‘Other’, the page displays the Contact Description as a required field. While Contact Description is hidden, you can save the new Contact.

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Contact">    <models>
        <model id="Contact" limit="1" query="false" createrowifnonefound="true" datasourcetype="salesforce" datasource="salesforce" sobject="Contact">
                <field id="FirstName"/>
                <field id="LastName"/>
                <field id="LeadSource"/>
                <field id="Description"/>
        <pagetitle model="Contact" uniqueid="sk-3veJd8-92">
                <template>New {{Model.label}}</template>
                <action type="savecancel" afterCancel="/{{Model.KeyPrefix}}/o" afterSave="/{{Id}}" rollbackonanyerror="true"/>
        <basicfieldeditor showsavecancel="false" showheader="true" model="Contact" mode="edit" uniqueid="sk-3veJd8-93">
                <column width="50%">
                        <section title="Basics">
                                <field id="FirstName"/> <field id="LastName"/>
                <column width="50%">
                        <section title="Additional Info" collapsible="no">
                                <field id="LeadSource"/>
                                <field id="Description" valuehalign="" type="" required="true">
                                    <renderconditions logictype="and" onhidedatabehavior="keep">
                                        <rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="true" fieldmodel="Contact" sourcetype="fieldvalue" field="LeadSource" fieldtargetobjects="Contact" value="Other"/>
        <styleitem type="background" bgtype="none"/>



^^ This is what we do.  Have the field twice on the page, one required and one not.  Conditionally show the correct field based on the situation.

Yeah that’s what we do now but you should be able to do it programmatically.

Hey Skuid!

Any way to do this programaticallly? Having two versions of the field with conditional rendering doesn’t work when I’m using a table.