For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2005 > Quickform select freeze problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Quickform select freeze problem
Massimiliano Arione

2005-05-26, 8:59 pm

There's a strange behaviout in freezing select elements in QF.
I want an empty (zero) value in the top of array I use for select
fields, to display a nice label (e.g, "choose one").
I don't put it directly in the array since I need to validate
(server-side) choosen option against the array (via a simple registerrule)
But... when I freeze the form, I don't get the choosen option!
Instead, I get the "choose" option (I understand it sound a bit
confusing, it's simpler to try than to explain)

Example code:


<?php
require_once 'HTML/QuickForm.php';
$arr = array('a' => 'this is a', 'b' => 'this b', 'c' => 'this c');
$form =& new HTML_QuickForm('mytest');
$form->addElement('text', 'mytext', 'text');
$form->addElement('select', 'mysel', 'abc', array('choose') + $arr);
$form->addElement('submit', 'ok', 'OK');
if ($form->validate()) {
$form->freeze();
$form->removeElement('ok');
}
echo $form->toHtml();
?>

Tried to look into QF source code, but no success.
Am I missing something?
TIA

--
Massimiliano Arione
:: http://www.garak.it/ ::
* NO WORD * http://gnu.org/philosophy/no-word-attachments.html
* NO HTML * http://efn.no/html-bad.html
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com