0

If i have a custom object, and I want to pass it as the form value in a radio button selection - then I have to do the following;

<input type="radio" name="appNames" value="<?php echo $app ?>"> <?php echo $name ?><br>

Now - this seems to just invoke toString() on my object meaning that when I pick it up later down the line, it is just a String.

Passing the following also does not work - my question therfore is - how can i pass this information to the next page?

<input type="radio" name="appNames" value="<?php $app ?>"> <?php echo $name ?><br>

Would adding it to a session be the correct approach?

Thanks

1
  • What is the purpose ? It seems to have no interest. But if you want to save variable through pages, use the session. Commented Jun 15, 2014 at 19:22

1 Answer 1

1

You can only "pass" through an HTML form whatever you can store in HTML attributes, which is text. You could serialize the whole object to store it in an attribute, but that's quite a weird approach.

You should be storing some identifying value in the HTML attribute that allows you to reconstruct the object later. Typically you store an id or something similar, and then have a lookup table/array what kind of object belongs to which id. If you need to store more state than that, then yes, you should probably store that in the session.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.