views:

211

answers:

1

Let's say I've got form like this:

$form = new HTML_QuickForm('Novinky');  
$defaults = array('text' => '');
$form->setDefaults($defaults);
$elements['text'] = $form->addElement('textarea', 'text', 'Text', array('cols'=>55, 'rows'=>10, 'id'=>'text'));
$form->addElement('submit','save','Save');
if (isset($_POST[save])) {
    if ($form->validate()) {   
     $form->process(array($this,'writeDB'));
    }
}

After submit I want the default value to be shown instead of the value entered by user. Does Quickform have some functionality to achieve that or do I have to use something clumsy like:

$elements['text']->setValue( $defaults['text']);

.. in which case the setDefaults method seems bit useless to me...

A: 

you could use

$form->exportValue('text');
streetparade
Documentation says: This method first tries to find a cleaned-up submitted value, it will return a value set by setValue()/setDefaults()/setConstants() if submitted value does not exist for the given element.... So I guess that doesn't solve my problem :/
Corvus