Setting Value for ValidForm Builder
I am trying to give an email field a value gathered from the database, but it's not working as a $meta entry and there no documentation on how to set the value:
//*** Special e-mail address validation
$objForm->addField("paypal_id","Paypal Account", VFORM_EMAIL,
array("required" => false),
array("type" => "This is no开发者_StackOverflowt a valid e-mail address!"),
array("tip" => "Your paypal account email address", "value"=>"test") //not working
);
Anyone have any experience with this class?
I am one of the developers who created ValidForm Builder.
The "default" meta value is the way to go. You can optionally set a "hint" meta value instead of the 'default' to set a default value that cannot be submitted as a value (it will not validate).
//*** Using the 'default' meta
$objForm->addField("paypal_id","Paypal Account", VFORM_EMAIL,
array("required" => false),
array("type" => "This is not a valid e-mail address!"),
array(
"tip" => "Your paypal account email address",
"default" => "Default value" // Valid value to submit
)
);
//*** Using the 'hint' meta
$objForm->addField("paypal_id","Paypal Account", VFORM_EMAIL,
array("required" => false),
array("type" => "This is not a valid e-mail address!"),
array(
"tip" => "Your paypal account email address",
"hint" => "Hint value" // Will trigger an error if 'Hint value' is submitted
)
);
Used default instead of value in the $meta array
try this
//*** Special e-mail address validation
$objForm->addField("paypal_id","Paypal Account", VFORM_EMAIL,
array("required" => false),
array("type" => "This is not a valid e-mail address!"),
array("tip" => "Your paypal account email address", "default"=>"test")
);
精彩评论