|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Adding styles to labels using Zend_FormHi,
I want to hide a form element using inline CSS. Now, I can add a style attribute to the input element, but is it also possible to manipulate attributes in the Label decorator? (Either in the label or the surrounding dt) Thanks, -- Vincent |
|
|
Re: Adding styles to labels using Zend_Form-- Vincent <imnotb@...> wrote
(on Monday, 09 June 2008, 04:10 PM +0200): > I want to hide a form element using inline CSS. Now, I can add a style > attribute to the input element, but is it also possible to manipulate > attributes in the Label decorator? (Either in the label or the surrounding dt) You can provide attributes to the Label decorator via the options you pass to it on creation (or by calling setOption() on the object instance). However, it is not possible at this time to set attributes on the tag surrounding it. -- Matthew Weier O'Phinney Software Architect | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Adding styles to labels using Zend_FormUse Unobtrusive JavaScript.[1] I recommend jQuery.[2]
[1] http://en.wikipedia.org/wiki/Unobtrusive_JavaScript [2] http://www.jquery.com/ On Mon, Jun 9, 2008 at 5:40 PM, Vincent <imnotb@...> wrote: Hi, |
|
|
Re: Adding styles to labels using Zend_FormOn 6/9/08, Matthew Weier O'Phinney <matthew@...> wrote: -- Vincent <imnotb@...> wrote Ah, excellent! It's not documented AFAICS but it's still odd that I missed it while browsing through the source. Thanks! On 6/10/08, AmirBehzad Eslami <behzad.eslami@...> wrote: Use Unobtrusive JavaScript.[1] I recommend jQuery.[2] That wouldn't be appropriate in this case as I want to hide it using purely CSS. -- Vincent |
|
|
Re: Adding styles to labels using Zend_FormHello, some words about me : i am new to Php and to ZF too (1 week), so excuse me if I say big mistakes :) (and for my french english) Like Vincent, I have a problem with decorating label, especially, decorating surrounding label tag. I modified the Label.php class to support a new option 'classTag' like this : line 303 (version 1.5.2) if (null !== $tag) { require_once 'Zend/Form/Decorator/HtmlTag.php'; $decorator = new Zend_Form_Decorator_HtmlTag(); // By default was : //$decorator->setOptions(array('tag' => $tag)); if (!empty($options) && isset($options['classTag'])) { $classTag = $options['classTag']; $decorator->setOptions(array('tag' => $tag, 'class' => $classTag)); } else { $decorator->setOptions(array('tag' => $tag)); } $label = $decorator->render($label); } Then i can have the following output : <td class="labelTd"><label ... /></td> with the following call : $inpuDecorator = (array( 'ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'inputTd')), array(array('label' => 'Label'), array('tag' => 'td', 'classTag' => 'labelTd', 'class' => 'labelClasse')), )); instead of default behavior : <td><label class="labelTd"... /></td> @Matthew : the problem is that this code generates non valid html code, since label uses FormElement _htmlAttribs(...) method, and generate this : <td class="labelTd"><label for="subform2-nationalite" classTag="labelTd" class="labelClasse optional">Nationalité</label></td> Is this 'bug' being fixed ? Or what is the best way to implement this behavior, and making valid html code ? Regards |
| Free Forum Powered by Nabble | Forum Help |