Jump to content

Using InputField in a Form, default value?


paulkoan
 Share

Recommended Posts

Hello, I am using the form API for forms, and I have some defaults that are saved via a cookie.

So if someone has visited the site previously, if they return to complete a query form etc, the idea is that these are prepopulated in the form.

I am using InputFields and using $fieldname->render() to create the form fields.   Can I just set the value of an Input field (after first checking we are not in the middle of a POST)?

What I don't get is when Inputfield get populated from POST - it seems to be populated as soon as it gets instanced, because if the form is completed, but has errors, the form field contents get remembered from the POST, even through I haven't done a processInput yet.

I am guessing I can't just say

$nameformfield->value ? $formfield->value : $_COOKIE['name'];

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...