My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 07, 2009 by tobiasz.cudnik
valuesToFormMethodPHP  

valuesToForm

Wiki > Syntax > valuesTo > valuesToForm

Parameters

Description

Toggles form fields values and selection states according to static values from $values.

This includes:

Inputs are selected according to $selectorPattern, where %k represents variable's key.

Method doesn't change selected elements stack.

Example

 $data = array(
   'text-example' => 'new',
   'checkbox-example' => true,
   'radio-example' => 'second',
   'select-example' => 'second',
   'textarea-example' => 'new',
 );
 $template->valuesToForm($data);

Source

 <form>
   <input type='text' name='text-example' value='old'>
   <input type='checkbox' name='checkbox-example' value='foo'>
   <input type='radio' name='radio-example' value='first' checked='checked'>
   <input type='radio' name='radio-example' value='second'>
   <select name='select-example'>
     <option value='first' selected='selected'>first</option>
     <option value='second'>second</option>
   </select>
   <textarea name='textarea-example'>old</textarea>
 </form>

Result

 <form>
   <input type='text' name='text-example' value='new'>
   <input type='checkbox' name='checkbox-example' value='foo' checked='checked'>
   <input type='radio' name='radio-example' value='first'>
   <input type='radio' name='radio-example' value='second' checked='checked'>
   <select name='select-example'>
     <option value='first'>first</option>
     <option value='second' selected='selected'>second</option>
   </select>
   <textarea name='textarea-example'>new</textarea>
 </form>

See also

Comments allowed


Sign in to add a comment
Hosted by Google Code