I might sound a bit weird but, is there a way? For example, I have a PHP object $foo.
$foo
Is there a way to store this object in an HTML form (hidden input)
You can use the serialize and unserialize methods:
serialize
unserialize
$serialized = serialize($foo);
Now you can store $serialized in your hidden input field. Later, you can read it back and convert to object with unserialize method. For example:
$serialized
$foo = unserialize($_POST['my_hidden_field']); // back to object