[PHPLIB] default hidden input "form_name" not generated by tpl_form From: Andy Choi (andy <email protected>)
Date: 03/08/00

Hi,

After reading thought the documentation, I decided to have a tpl_form
for myself. Following the example, I subclass tpl_form (call it myForm)
and an .ihtml file. Since the form would have some first-time default
values, i decide to override process_default in myForm such that i uses
get_default_values to create the initial array and then pass the array
(with modification) into set_default_value. However, using this
mechanism the hidden field will not be generated because the array for
default values do not assign a value to "form_name".

Consider this:
function process_default() {
    $default = get_default_value();
    ...
    ...
    ...
    set_default_value ($default); /* There's no value assigned to
$default['form_name'] at this point. */
}

Eventually, when you call display on myForm, oh_hidden->self_get is
invoked with arguments ("", Array, ...). Note that the first argument is
"" and thus, nothing would be generated if the member variable $value of
of_hidden is also "". Unfortunatly, this is exactlly the case!! Since
the array passed to set_default_value does not have a value set for
'form_name', the call to myForm->display would not assign a non-"" value
to of_hidden->value (via oohform->load_defaults).

Knowing all those, now i can solve the problem by adding this line
before the call to set_default_value:

$defaults["form_name"]=$this->classname;

and it works.

Now, I am wondering should this line be included somewhere in the
super-class? Any comments on my use of the tpl_form class?

Thanks,
Andy

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.