Re: [studs-user] New HTML tag for checkbox
Status: Beta
Brought to you by:
mojavelinux
|
From: Dan A. <dan...@gm...> - 2005-07-06 03:16:57
|
Okay, I merged this in and then some. I am prototyping the ability to work with multiple values, which has not been a feature of Studs up to this point. It looks like it isn't going to be too much trouble. The checkbox will be in CVS shortly. /dan On 7/2/05, Greg Heartsfield <sc...@im...> wrote: > I've created a new tag for an HTML checkbox. The source is included > below. The only other change required is that you update WEB-INF/tld/ > studs-html.tld to include an extra tag entity: > <tag> > <name>checkbox</name> > <tag-class>studs.taglib.html.HtmlCheckboxTag</tag-class> > </tag> >=20 > I haven't tested it heavily, but it is currently working for my > project. This was a little bit trickier to get working than the > password tag, but not much so. >=20 > In case the text below gets mangled, the source is available at > http://scsibug.com/HtmlCheckboxTag.php.txt >=20 > Thanks, > Greg Heartsfield >=20 >=20 > <?php > /* $Id: HtmlCheckboxTag.php,v 1.2 2005/07/03 02:10:52 ghphoto Exp $ > * > * Copyright 2003-2005 Dan Allen, Mojavelinux.com > (dan...@mo...) > * > * This project was originally created by Dan Allen, but you are > permitted to > * use it, modify it and/or contribute to it. It has been largely > inspired by > * a handful of other open source projects and public specifications, > most > * notably Apache's Jakarta Project and Sun Microsystem's J2EE SDK. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ >=20 > import('studs.taglib.html.BaseInputTag'); > import('studs.taglib.TagUtils'); >=20 >=20 > /** > * @package studs.taglib.html > * @author Greg Heartsfield > * @author Dan Allen > */ > class HtmlCheckboxTag extends BaseInputTag > { >=20 > function renderTag() > { > if (!is_null($this->value)) > { > $value =3D $this->value; > } > else > { > $value =3D htmlspecialchars(TagUtils::lookup($this- > >pageContext, c('StudsConstants::BEAN_KEY'), $this->property)); > } >=20 > // Set returned value for checked box depending on > existing nomenclature > $on_value =3D 1; > if ($value =3D=3D 'on' || $value =3D=3D 'off') > { > $on_value =3D 'on'; > } > else if ($value =3D=3D 'true' || $value =3D=3D 'false') > { > $on_value =3D 'true'; > } >=20 > if (is_null($this->styleId)) > { > $this->styleId =3D $this->property; > } >=20 > $xhtml =3D '<input type=3D"checkbox" name=3D"' . $this- > >property . '" value=3D"' . $on_value . '"'; >=20 > if ($value =3D=3D '1' || $value =3D=3D 'on') > { > $xhtml .=3D ' checked =3D "checked"'; > } >=20 > $xhtml .=3D $this->renderStyleAttributes(); > $xhtml .=3D $this->renderMetaAttributes(); > $xhtml .=3D ' />'; > return $xhtml; > } > } > ?> >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=3D7477&alloc_id=3D16492&op=3Dclic= k > _______________________________________________ > studs-user mailing list > stu...@li... > https://lists.sourceforge.net/lists/listinfo/studs-user >=20 --=20 Open Source Advocacy http://www.mojavelinux.com |