setValue()
clonefish->setValue() - set the value of a form element
Description
class clonefish { mixed setValue( string $name, mixed $value, boolean $magic_quotes_gpc ) }
Sets the value of an element and strips slashes using stripslashes()
if needed.
It is a helpful shortcut instead of:
$element = $clonefish->getElementByName('fieldname'); $element->setValue( 1 );
Parameters
$name
The name of the form element
$value
The value to set
$magic_quotes_gpc
Whether or not slashes are already added to the returned value.
Return values
Returns TRUE
if the value is set successfully, returns FALSE
if the element is not found.
Examples
Example 1: we have a login
and a password
field in our form.
<?php echo $clonefish->setValue( 'login', 0 ) ? 'OK' : 'failed'; echo "\n"; echo $clonefish->setValue( 'password', 0 ) ? 'OK' : 'failed'; echo "\n"; echo $clonefish->setValue( 'description', 0 ) ? 'OK' : 'failed'; ?>
Output:
OK OK failed
form validation for developers!
clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain formslearn more