title: Can I set two values for a submit button?
body: <p><strong><em>Note:</strong> This is a rewrite of an old post to clarify what was being asked.</em></p>
  
  <p>Let's suppose I have a single form that displays a set of rows (for example, lines in an order), and I want to place a "delete" button besides each row, but unfortunately I can't create a single form for every row.</p>
  
  <p>In addition let's say that the form goes to a "generic action route" that is the "editCart" controller.</p>
  
  <p>For the sake of the example, let's assume in the form there are several other actions, like for example adding one to the quantity.</p>
  
  <p>This has to be done with multiple submit buttons within the same form.</p>
  
  <p>If it was only one single row, it is easy, just add a name/value to the button and boom! done!.</p>
  
  <pre><code>&lt;form action="/process-edition" method="post"&gt;
      &lt;div&gt;My nice things&lt;/div&gt;
      &lt;button type="submit" name="subAction" value="delete"&gt;Delete&lt;/button&gt;
      &lt;button type="submit" name="subAction" value="addOne"&gt;+1&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is saying "hey, controller of the action <code>/process-edition</code>, I'm going to make the subAction <code>delete</code>". Or "the subAction <code>addOne</code>".</p>
  
  <p>But when we have multiple rows, you need to say something like "delete THIS product" or "add one of THIS product".</p>
  
  <p>In this case you need that the button submits like two values: a) the subAction, b) the id of the product to be edited.</p>
  
  <pre><code>&lt;form action="/process-edition" method="post"&gt;
      &lt;ul&gt;
          &lt;li&gt;
              Product 1234: 'orange'
              &lt;button type="submit" name="subAction" value1???="delete" value2???=1234&gt;Delete&lt;/button&gt;
              &lt;button type="submit" name="subAction" value1???="addOne" value2???=1234&gt;+1&lt;/button&gt;
          &lt;/li&gt;
          &lt;li&gt;
              Product 6789: 'lemmon'
              &lt;button type="submit" name="subAction" value1???="delete" value2???=6789&gt;Delete&lt;/button&gt;
              &lt;button type="submit" name="subAction" value1???="addOne" value2???=6789&gt;+1&lt;/button&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I think in this case <code>delete</code> and <code>addOne</code> is what the original post was asking as a "statically assigned value" and the <code>1234</code> and <code>6789</code> would be the "hidden" values that come from the database. The button "knows" about the Id but does not display the Id itself.</p>
  
  <p>Of course this could be resolved by setting multiple forms to several different controllers with hidden fields in each form. But let's assume you are constricted to a layout that already has the form and you cannot create several forms in it, thus forbidding you to isolate hidden fields to be sent or not sent.</p>
  
  <p>ORIGINAL TEXT OF THE POST:</p>
  
  <p>one value has to be hidden from the user and another has to be displayed.The hidden value is retrieved from the database and the displayed one is statically assigned value?</p>