title: Dynamic changes in rails form (simpleform)
body: <p>I'm trying to make a simple form with this general structure:</p>
  
  <pre><code>o accept  o decline
  [submit]
  </code></pre>
  
  <p>when the radio button accept is checked and submit pressed, I want it to change the state of my model (called Offer here).
  BUT when the button decline is checked, the form needs to change to something like this:</p>
  
  <pre><code>o accept  x decline
  Please enter reason here: [text box]
  [submit]
  </code></pre>
  
  <p>Having entered a (mandatory) reason for declining and pressing submit, will change the state of the model Offer too, but differently.</p>
  
  <p>I'm currently having problems getting the form to display the way I want. I'm using SimpleForm and tried something like this:</p>
  
  <pre><code>&lt;%= simple_form_for @offer do |f| %&gt;
    &lt;%= f.input accepts, as: :radio_buttons %&gt;
    &lt;%= f.input :r_comment, as: :text, :label =&gt; 'Please enter reason here:' , :input_html =&gt; { :rows =&gt; 2, } %&gt;
    &lt;%= f.button :submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This of course doesn't work, because there is no "accepts" method or variable defined for offers (and it shouldn't be!). As for dynamically showing the input text box, I don't even have the slightest clue.</p>
  
  <p>I'd be glad for any help you might offer,</p>
  
  <p>Lordylike</p>
  
  <p>UPDATE: HTML generated by simple_form</p>
  
  <pre><code>&lt;div class="control-group radio_buttons optional"&gt;
    &lt;label class="radio_buttons optional control-label"&gt;Accept?&lt;/label&gt;
    &lt;div class="controls"&gt;
      &lt;label class="radio"&gt;
        &lt;input class="radio_buttons optional" id="offer_accepts_decline" name="offer[accepts]" type="radio" value="Decline" /&gt;
        Decline
      &lt;/label&gt;
      &lt;label class="radio"&gt;
        &lt;input class="radio_buttons optional" id="offer_accepts_accept" name="offer[accepts]" type="radio" value="Accept" /&gt;
        Accept
      &lt;/label&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>UPDATE: HTML generated for comment box</p>
  
  <pre><code>&lt;div class="control-group text optional"&gt;
      &lt;label class="text optional control-label" for="offer_r_comment"&gt;Reason for rejection:&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;textarea class="text optional" cols="40" id="offer_r_comment" name="offer[r_comment]" rows="2"&gt;
          &lt;/textarea&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>