Re: Formbuilder generates extra radio button
| From: | Justin Patrin | Date: | Wed, 20 Jul 2005 22:51:49 +0000 |
| Subject: | Re: Formbuilder generates extra radio button | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20082@lists.php.net to get a copy of this message | ||
On 7/20/05, Andrew Wooldridge <andrew.r.wooldridge@vanderbilt.edu> wrote:
> I'm using the following code to create a yes, no, unknown field using
> FormBuilder. The data field is a char(1) in my database. I have the
> following lines in my dataobject class. However, the HTML created has a
> fourth radio button, without a label, before the others.
>
> ---partial listing of options set in data object---
> public $y_n_u; // string(1)
>
> $this->fb_linkElementTypes = array('y_n_u' => 'radio');
>
> $this->fb_enumFields[] = 'y_n_u';
>
> $this->fb_enumOptions = array('y_n_u' => array('Y' =>
> 'Y',
> 'N' => 'N',
> 'U' => 'U') );
>
> ---HTML generated -----
>
> <td valign="top" align="center">
> <input name="test1_y_n_u_1" value="" type="radio"
> id="qf_51da48"
> checked="checked" />
> <input name="test1_y_n_u_1" value="Y" type="radio"
> id="qf_47f93e"
> /><label for="qf_47f93e">Y</label>
> <input name="test1_y_n_u_1" value="N" type="radio"
> id="qf_4facaf"
> /><label for="qf_4facaf">N</label>
> <input name="test1_y_n_u_1" value="U" type="radio"
> id="qf_7a549b"
> /><label for="qf_7a549b">U</label></td>
>
> -----------------------------
>
> Has anyone else seen this problem before?
It's not a problem, it's a feature. ;-)
I'm pretty sure that what's happening is that FormBuilder is adding an
extra option because the field is allowed to be NULL. I.e. it's not
NOT NULL. If you change your field in the DB to NOT NULL and
regenerate your DO ini file you'll see that go away.
You may be right in a way, though...a "nothing" radio button doesn't
make as much sense as a "nothing" select box entry. However, not
having the "nothing" radio button means that once you click yes or no
you won't be able to go back to choosing nothing in most browsers.
I suggest you just make your field NOT NULL. :-)
--
Justin Patrin