title: simple_form: disable form without adding disabled: true or readonly: true to every input
body: <p>I have a large <i>simple_form</i> form with fields that need to be <i>enabled</i> or <i>disabled</i> depending upon where the form's partial gets loaded.</p>
  <p>My question is:   <b>how do you <i>disable every form input</i> quickly</b> using simple_form helpers / wrappers?</p>
  <p><a href="http://www.rubydoc.info/github/plataformatec/simple_form/master/frames" rel="nofollow noreferrer">Simple Form's documentation</a> explains how <code>disabled: true</code> can be used to disable a <i>single input field</i>:</p>
  <pre><code>&lt;%= simple_form_for @user do |f| %&gt;
    &lt;%= f.input :username, disabled: true %&gt;
    &lt;%= f.button :submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>But the documentation is less clear on how I can <i>disable an entire form</i> via simple_form helpers without needing to repeat <code>disabled: true</code> on <i>literally every form input.</i></p>
  <p>I tried passing <code>disabled: true</code> and <code>readonly: true</code> to simple_form's <code>:wrapper_mappings</code> option, but that isn't working.</p>
  <hr />
  <h3>Example Code:</h3>
  <p>I load the form via a partial to define simple_form display variables.  This works:</p>
  <pre><code>#user/show.html.erb:
  &lt;%= render partial: 'shared/form', locals: {questionnaire: @questionnaire, readonly_state: true, disabled_state: true, bootstrap_form_class: 'form-horizontal'} %&gt;
  </code></pre>
  <p>However, <i>readonly_state</i> and <i>disabled_state</i> do not work unless I pass them to every form input:</p>
  <pre><code># shared/_form.html.erb
  &lt;%= simple_form_for(@questionnaire, :html =&gt; {:class =&gt; bootstrap_form_class}, 
  
  :wrapper_mappings =&gt; {check_boxes: :vertical_radio_and_checkboxes, file: :vertical_file_input,
  boolean: :vertical_boolean  }) do |f| %&gt;
  
    &lt;%= f.input :username, disabled: disabled_state, hint: 'You cannot change your username.' %&gt;
    &lt;%= f.input :email, disabled: disabled_state %&gt;
    &lt;%= f.input :city, disabled: disabled_state %&gt;
    &lt;%= f.input :country, disabled: disabled_state %&gt;
    . . .
    &lt;%= f.button :submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  <hr />
  <p>You can quickly see how repetitious this gets with a large form.</p>
  <h2>How do I toggle <em>disable</em> and <em>readonly</em> form attributes quickly across an entire form using DRY code?</h2>