Home > Archive > PHP Pear > July 2005 > Re: [PEAR] Formbuilder generates extra radio button
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 |
Re: [PEAR] Formbuilder generates extra radio button
|
|
| Justin Patrin 2005-07-24, 8:39 pm |
| 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.
>=20
> ---partial listing of options set in data object---
> public $y_n_u; // string(1)
>=20
> $this->fb_linkElementTypes =3D array('y_n_u' =3D> 'radio');
>=20
> $this->fb_enumFields[] =3D 'y_n_u';
>=20
> $this->fb_enumOptions =3D array('y_n_u' =3D> array('Y' =3D> 'Y',
> 'N' =3D> 'N',
> 'U' =3D> 'U') );
>=20
> ---HTML generated -----
>=20
> <td valign=3D"top" align=3D"center">
> <input name=3D"test1_y_n_u_1" value=3D"" type=3D"radio" id=3D"qf_51da=
48"
> checked=3D"checked" />
> <input name=3D"test1_y_n_u_1" value=3D"Y" type=3D"radio" id=3D"qf_47f=
93e"
> /><label for=3D"qf_47f93e">Y</label>
> <input name=3D"test1_y_n_u_1" value=3D"N" type=3D"radio" id=3D"qf_4fa=
caf"
> /><label for=3D"qf_4facaf">N</label>
> <input name=3D"test1_y_n_u_1" value=3D"U" type=3D"radio" id=3D"qf_7a5=
49b"
> /><label for=3D"qf_7a549b">U</label></td>
>=20
> -----------------------------
>=20
> Has anyone else seen this problem before?=20
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. :-)
--=20
Justin Patrin
| |
| Andrew Wooldridge 2005-07-24, 8:39 pm |
| I've changed the database and regenerated the dataobjects using
createTables.php. Sadly I still see four rather than the expected three.
If your next suggestion is to use a select instead of radio buttons, can you
tell me how to make 'Unknown' the default rather than 'null'? :) -A
On 7/20/05 5:51 PM, "Justin Patrin" <papercrane@gmail.com> wrote:
> On 7/20/05, Andrew Wooldridge <andrew.r.wooldridge@vanderbilt.edu> wrote:
>
> 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 2005-07-24, 8:39 pm |
| On 7/20/05, Andrew Wooldridge <andrew.r.wooldridge@vanderbilt.edu> wrote:
> I've changed the database and regenerated the dataobjects using
> createTables.php. Sadly I still see four rather than the expected three.
> If your next suggestion is to use a select instead of radio buttons, can =
you
> tell me how to make 'Unknown' the default rather than 'null'? :) -A
Are you sure that particular field is set up as "NOT NULL"? If it is
then this is likely a bug, as you said, although I have no idea how it
could be happening. Do you perhaps have selectAddEmpty set to true?
Setting selectAddEmptyLabel *should* change the text. If it doesn't
let me know and I'll look into it.
>=20
>=20
>=20
> On 7/20/05 5:51 PM, "Justin Patrin" <papercrane@gmail.com> wrote:
>=20
e:[color=darkred]
a[color=darkred]
Y',[color=darkred]
;[color=darkred]
1da48"[color=darkred]
47f93e"[color=darkred]
4facaf"[color=darkred]
7a549b"[color=darkred]
>=20
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>=20
>=20
--=20
Justin Patrin
|
|
|
|
|