title: How do I pass an object into a hidden form in php?
body: <p>I have an object called $todovalues and a form. I need to pass the entirety of the todovalues object through the form.</p>
  
  <p>My form looks like -</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
  &lt;input class="todobuttons" type="submit" name="delete" value="delete"&gt;
  &lt;input class="todobuttons" type="submit" name="edit" value="edit"&gt;
  &lt;input type="hidden" name="post_item_info"
  value="&lt;?php echo serialize($todovalues); ?&gt;"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I can access the values in $todovalues by using something like echo $todovalues->text.</p>
  
  <p>I have tried to use serialize, json_encode, and a mixture of both. However, when I try to access the post value it is always empty.</p>
  
  <p>Is there a way to take my object and add it to the hidden input without having to create individual hidden inputs for each piece of the object that I want?</p>
  
  <pre><code>json_encode($todovalues);
  json_encode(serialize($todovalues));
  serialize($todovalues);
  </code></pre>
  
  <p>None of the above have been functional yet. Is there no simplified method to pass the whole of an object without iterating through the object first? It just seems like a waste of space to have to create hidden inputs for each item in the object.</p>
  
  <p>EDIT - </p>
  
  <p>When I use json_encode() I see the following so I know it SHOULD exist -</p>
  
  <pre><code>&lt;input type="hidden" name="post_item_info" value="{" id_auto":"3","id":"1","id_list":"1","completed":"0","incident_notes":"apple"}"=""&gt;
  </code></pre>