title: MVC Sending Values to Form
body: <p>I have been making a site to learn about MVC, I am trying to add a function to the update option. At the moment I have two buttons on each row (one to delete and one to update), when the update button is pressed a form to update the row appears on the right of the screen. </p>
  
  <p>I am trying to pre-populate the form when the user presses the update the button but I dont know how to do that within an MVC. Should I create a function that does this or should I have some PHP at the top of the form to pre-populate?</p>
  
  <p>Any help or advice will be great </p>
  
  <p><strong>Update Form to be pre-populated</strong></p>
  
  <pre><code>&lt;h2&gt;Update Item!&lt;/h2&gt;
      &lt;h4&gt;Fill in the form to update an entry.&lt;/h4&gt;
      &lt;form action="index.php" method="post"&gt;
          &lt;fieldset&gt;
              &lt;input id='action' type='hidden' name='action' value='updateItem' /&gt;
              &lt;p&gt;
                  &lt;label for="fTitle"&gt;Title&lt;/label&gt; &lt;input type="text"
                      id="fTitle" name="fTitle" placeholder="title"
                      maxlength="25" required /&gt;
              &lt;/p&gt;
              &lt;p&gt;
                  &lt;label for="fPrice"&gt;Price&lt;/label&gt; &lt;input type="text"
                      id="fPrice" name="fPrice" placeholder="price"
                      maxlength="25" required /&gt;
              &lt;/p&gt;
              &lt;p&gt;
                  &lt;label for="fDescription"&gt;Description&lt;/label&gt; &lt;input type="text"
                      id="fDescription" name="fDescription" placeholder="description"
                      maxlength="500" required /&gt;
              &lt;/p&gt;
  
              &lt;p&gt;
              &lt;div class="form-group"&gt;
                  &lt;div class="controls"&gt;
                      &lt;button type="submit" class="btn btn-success"&gt;Update&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;/p&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>Update button in the View receiving the row ID for the button</strong></p>
  
  <pre><code>            $update = file_get_contents( "templates/updateButton.php");
              $HTMLItemList = "";
              foreach ( $this-&gt;model-&gt;itemList as $row ) 
                      $HTMLItemList .= "&lt;li&gt;&lt;strong&gt;" . $row ["title"] . ": &lt;/strong&gt;" . "€" .$row ["price"] . "&lt;blockquote&gt;" . 
                          $row ["description"] .  " " . str_replace("value2replace", $row['id'], $delete) . 
                          str_replace("value2replace", $row['id'], $update) . "&lt;/blockquote&gt;&lt;/li&gt;";
  </code></pre>
  
  <p><strong>Update Button</strong></p>
  
  <pre><code>&lt;form action="index.php" method="post"&gt;
          &lt;fieldset&gt;
              &lt;input id='action' type='hidden' name='action' value='updateStart' /&gt;
              &lt;div class="form-group"&gt;
                  &lt;div class="controls"&gt;
                      &lt;input type="hidden" id="fId" name="fId" value="value2replace"&gt; 
                      &lt;input type="submit" class="btn btn-success" value="Update" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  </code></pre>