<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to allow a checkbox to create a greyed out/disabled field</title><link>https://community.appian.com/discussions/f/user-interface/11043/how-to-allow-a-checkbox-to-create-a-greyed-out-disabled-field</link><description>Hi everyone, 
 
 This may be a simple fix, but I cannot get it right. I have created a form where the user can input their SSN. If they do not have a SSN, they have to check a checkbox and the field for Social security number should become greyed out</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to allow a checkbox to create a greyed out/disabled field</title><link>https://community.appian.com/thread/48327?ContentTypeID=1</link><pubDate>Thu, 07 Sep 2017 23:29:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3122510f-f26a-4792-866a-73c7f4681521</guid><dc:creator>aloks0189</dc:creator><description>&lt;p&gt;Hi dcuser12 Also you can have a look into this sample code for your requirement, where the SSN field gets disabled and empty when a user click on the Checkbox.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!checkbox,
  local!SSN,
  a!formLayout(
    label: &amp;quot;Test Form&amp;quot;,
    contents: {
      a!textField(
        label: &amp;quot;SSN&amp;quot;,
        value: local!SSN,
        saveInto: local!SSN,
        disabled: if(
          not(isnull(local!checkbox)),
          local!checkbox,
          false()
        )
      ),
      a!checkboxField(
        choiceLabels: {&amp;quot;I don&amp;#39;t have SSN&amp;quot;},
        choiceValues: {true()},
        value: local!checkbox,
        saveInto: {
          local!checkbox,
          a!save(local!SSN, null())
        }
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hope this will help you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to allow a checkbox to create a greyed out/disabled field</title><link>https://community.appian.com/thread/48326?ContentTypeID=1</link><pubDate>Thu, 07 Sep 2017 23:28:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:66389ec3-f69c-4e9b-aa33-80f49bf211d8</guid><dc:creator>Omkar K</dc:creator><description>Please update your textField rule to following (Instead of readOnly, user disabled parameter from the textField):&lt;br /&gt;
rule!AF_CMPT_General_textField(&lt;br /&gt;
label: cons!SOCIAL_SECURITY_LABEL,&lt;br /&gt;
disabled: if(&lt;br /&gt;
isnull(&lt;br /&gt;
local!checkbox&lt;br /&gt;
),&lt;br /&gt;
false,&lt;br /&gt;
true&lt;br /&gt;
), &lt;br /&gt;
value: &lt;br /&gt;
if(&lt;br /&gt;
isnull(&lt;br /&gt;
local!checkbox &lt;br /&gt;
),&lt;br /&gt;
ri!boardUser.socialSecurityNumber,&lt;br /&gt;
{}&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
I hope, this helps.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to allow a checkbox to create a greyed out/disabled field</title><link>https://community.appian.com/thread/48324?ContentTypeID=1</link><pubDate>Thu, 07 Sep 2017 21:44:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8f03535e-07b7-4926-b6db-5bc40e2dfdfe</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;ve previously written a Boolean Checkbox component that pretty solidly satisfies most use cases I&amp;#39;ve found for a boolean checkbox - it involves a little bit of trickery to get it to work as one might expect.&amp;nbsp; I suggest you upgrade yours a bit, feel free to borrow from the below code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;=/*  Boolean Checkbox Component  */

a!checkboxField(
  label: ri!label,
  labelPosition: ri!labelPosition,
  instructions: ri!instructions,
  choiceLabels: {ri!checkboxLabel},
  choiceValues: {ri!trueValue},
  value: if(
    ri!value = ri!trueValue,
    ri!value,
    null()
  ),
  saveInto: {
    a!save(
      ri!saveInto,
      if(rule!APN_isEmpty(save!value), ri!falseValue, ri!trueValue)
    )
  },
  required: ri!required,
  disabled: ri!readOnly,
  validations: ri!validations,
  align: ri!align
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;For this component, you simply pass in values for &amp;quot;trueValue&amp;quot; and &amp;quot;falseValue&amp;quot; (in your case just pass in true() and false()), and make sure to handle the default value (i.e. initializing your local variable to a value of false()).&lt;/p&gt;
&lt;p&gt;Then for your SSN field, set the readOnly parameter just to the value of local!checkbox, no need to do the &amp;quot;if(isnull(local!checkbox)..&amp;quot; stuff.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;rule!AF_CMPT_General_textField(
  label: cons!SOCIAL_SECURITY_LABEL,
  readOnly: local!checkbox,
  value: if(
    local!checkbox,
    &amp;quot;&amp;quot;,
    ri!boardUser.socialSecurityNumber
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>