Re: [fw-general] Is there a way to set options on a tag surrounding a label?

2008-03-08 Thread Matthew Weier O'Phinney
-- Amr Mostafa <[EMAIL PROTECTED]> wrote
(on Saturday, 08 March 2008, 01:03 PM +0200):
> Pardon my rush there, I need to stop assuming that everyone lives on the
> subversion trunk :)
> Ok so here we go: This is going to work with the current trunk only or with 
> the
> next 1.5 release candidate :)

And it's also committed to the 1.5 release branch. :-)


> On Sat, Mar 8, 2008 at 1:01 PM, Amr Mostafa <[EMAIL PROTECTED]> wrote:
> 
> You could do that using the ViewScript decorator with the new content
> wrapping feature Matthew added few hours ago! :)
> 
> Here is your new setElementDecorators():
> 
> $form->setElementDecorators(array(
> array('ViewHelper'),
> array('ViewScript', array('viewScript' => 'element.phtml',
> 'placement' => false)),
> ));
> 
> Then in your element.phtml:
> 
>  require_once 'Zend/Form/Decorator/Label.php';
> $label = new Zend_Form_Decorator_Label();
> $label->setElement($this->element);
> ?>
> 
> 
> render('') ?>
> 
> 
> content ?>
> 
> 
> 
> One small note about the Label decorator, we could actually write the
>  tag ourselves like: element->getLabel() ?>
> But that's not good enough, what if the element doesn't have 'id' set?
> Label decorator is smart to fall back to the element name if id is not 
> set,
> and it has a bunch of other extras, like adding the optional/required
> classes, ...etc.
> 
> Best Regards,
> - Amr
> 
> 
> On Sat, Mar 8, 2008 at 4:55 AM, Karl Katzke <[EMAIL PROTECTED]> wrote:
> 
> I'm using Zend_Form to build a form, and I'd like to align all of the
> labels to the right inside their table cells. I can do this with 
> either
> CSS or the align="right" attribute of the table cell, but I would need
> to be able to set attributes on the tag... which by my read, currently
> isn't possible.
> 
> Sample decorator:
> 
>  46 $this->setElementDecorators(array(
>  47 'ViewHelper',
>  48 'Errors',
>  49 array('decorator'=>array('td'=>
> 'HtmlTag'),'options'=>array('tag'=>'td')),
>  50 array('Label',array('tag'=>'td')),
>  51 array('decorator'=>array('tr'=>
> 'HtmlTag'),'options'=>array('tag'=>'tr')),
>  52 ));
> 
> In Zend_Form_Decorator_Label, we're already using
> Zend_Form_Decorator_HtmlTag to render the tag option of the label.
> Could we add a tagoptions field to that Label decorator and pass the
> array of options through to the Zend_Form_Decorator_HtmlTag?
> 
> I'm a bit of a newb to Zend Framework, and this is deep enough inside
> the framework to make my head spin a bit, but it looks like a fairly
> simple addition. I'm just not sure how to execute it without breaking
> things further! I realize that everyone's in a rush to get the last 
> few
> changes in before the freeze, but I'd appreciate a hand with this if
> anyone has the time.
> 
> Thanks,
> Karl Katzke
> 
> 
> 
> 

-- 
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


Re: [fw-general] Is there a way to set options on a tag surrounding a label?

2008-03-08 Thread Amr Mostafa
Pardon my rush there, I need to stop assuming that everyone lives on the
subversion trunk :)
Ok so here we go: This is going to work with the current trunk only or with
the next 1.5 release candidate :)

Cheers,
- Amr

On Sat, Mar 8, 2008 at 1:01 PM, Amr Mostafa <[EMAIL PROTECTED]> wrote:

> You could do that using the ViewScript decorator with the new content
> wrapping feature Matthew added few hours ago! :)
>
> Here is your new setElementDecorators():
>
> $form->setElementDecorators(array(
> array('ViewHelper'),
> array('ViewScript', array('viewScript' => 'element.phtml',
> 'placement' => false)),
> ));
>
> Then in your element.phtml:
>
>  require_once 'Zend/Form/Decorator/Label.php';
> $label = new Zend_Form_Decorator_Label();
> $label->setElement($this->element);
> ?>
> 
> 
> render('') ?>
> 
> 
> content ?>
> 
> 
>
> One small note about the Label decorator, we could actually write the
>  tag ourselves like: element->getLabel() ?>
> But that's not good enough, what if the element doesn't have 'id' set?
> Label decorator is smart to fall back to the element name if id is not set,
> and it has a bunch of other extras, like adding the optional/required
> classes, ...etc.
>
> Best Regards,
> - Amr
>
>
> On Sat, Mar 8, 2008 at 4:55 AM, Karl Katzke <[EMAIL PROTECTED]> wrote:
>
> > I'm using Zend_Form to build a form, and I'd like to align all of the
> > labels to the right inside their table cells. I can do this with either CSS
> > or the align="right" attribute of the table cell, but I would need to be
> > able to set attributes on the tag... which by my read, currently isn't
> > possible.
> >
> > Sample decorator:
> >
> >  46 $this->setElementDecorators(array(
> >  47 'ViewHelper',
> >  48 'Errors',
> >  49
> > array('decorator'=>array('td'=>'HtmlTag'),'options'=>array('tag'=>'td')),
> >  50 array('Label',array('tag'=>'td')),
> >  51
> > array('decorator'=>array('tr'=>'HtmlTag'),'options'=>array('tag'=>'tr')),
> >  52 ));
> >
> > In Zend_Form_Decorator_Label, we're already using
> > Zend_Form_Decorator_HtmlTag to render the tag option of the label. Could we
> > add a tagoptions field to that Label decorator and pass the array of options
> > through to the Zend_Form_Decorator_HtmlTag?
> >
> > I'm a bit of a newb to Zend Framework, and this is deep enough inside
> > the framework to make my head spin a bit, but it looks like a fairly simple
> > addition. I'm just not sure how to execute it without breaking things
> > further! I realize that everyone's in a rush to get the last few changes in
> > before the freeze, but I'd appreciate a hand with this if anyone has the
> > time.
> >
> > Thanks,
> > Karl Katzke
> >
>
>


Re: [fw-general] Is there a way to set options on a tag surrounding a label?

2008-03-08 Thread Amr Mostafa
You could do that using the ViewScript decorator with the new content
wrapping feature Matthew added few hours ago! :)

Here is your new setElementDecorators():

$form->setElementDecorators(array(
array('ViewHelper'),
array('ViewScript', array('viewScript' => 'element.phtml',
'placement' => false)),
));

Then in your element.phtml:

setElement($this->element);
?>


render('') ?>


content ?>



One small note about the Label decorator, we could actually write the
 tag ourselves like: element->getLabel() ?>
But that's not good enough, what if the element doesn't have 'id' set? Label
decorator is smart to fall back to the element name if id is not set, and it
has a bunch of other extras, like adding the optional/required classes,
...etc.

Best Regards,
- Amr

On Sat, Mar 8, 2008 at 4:55 AM, Karl Katzke <[EMAIL PROTECTED]> wrote:

> I'm using Zend_Form to build a form, and I'd like to align all of the
> labels to the right inside their table cells. I can do this with either CSS
> or the align="right" attribute of the table cell, but I would need to be
> able to set attributes on the tag... which by my read, currently isn't
> possible.
>
> Sample decorator:
>
>  46 $this->setElementDecorators(array(
>  47 'ViewHelper',
>  48 'Errors',
>  49
> array('decorator'=>array('td'=>'HtmlTag'),'options'=>array('tag'=>'td')),
>  50 array('Label',array('tag'=>'td')),
>  51
> array('decorator'=>array('tr'=>'HtmlTag'),'options'=>array('tag'=>'tr')),
>  52 ));
>
> In Zend_Form_Decorator_Label, we're already using
> Zend_Form_Decorator_HtmlTag to render the tag option of the label. Could we
> add a tagoptions field to that Label decorator and pass the array of options
> through to the Zend_Form_Decorator_HtmlTag?
>
> I'm a bit of a newb to Zend Framework, and this is deep enough inside the
> framework to make my head spin a bit, but it looks like a fairly simple
> addition. I'm just not sure how to execute it without breaking things
> further! I realize that everyone's in a rush to get the last few changes in
> before the freeze, but I'd appreciate a hand with this if anyone has the
> time.
>
> Thanks,
> Karl Katzke
>


Re: [fw-general] Is there a way to set options on a tag surrounding a label?

2008-03-07 Thread Matthew Weier O'Phinney
-- Karl Katzke <[EMAIL PROTECTED]> wrote
(on Friday, 07 March 2008, 08:55 PM -0600):
> I'm using Zend_Form to build a form, and I'd like to align all of the labels 
> to
> the right inside their table cells. I can do this with either CSS or the 
> align=
> "right" attribute of the table cell, but I would need to be able to set
> attributes on the tag... which by my read, currently isn't possible.
> 
> Sample decorator:
> 
>  46 $this->setElementDecorators(array(
>  47 'ViewHelper',
>  48 'Errors',
>  49 array('decorator'=>array('td'=>
> 'HtmlTag'),'options'=>array('tag'=>'td')),
>  50 array('Label',array('tag'=>'td')),
>  51 array('decorator'=>array('tr'=>
> 'HtmlTag'),'options'=>array('tag'=>'tr')),
>  52 ));
> 
> In Zend_Form_Decorator_Label, we're already using Zend_Form_Decorator_HtmlTag
> to render the tag option of the label. Could we add a tagoptions field to that
> Label decorator and pass the array of options through to the
> Zend_Form_Decorator_HtmlTag?

You can file an issue if you'd like to see this feature. In the
meantime, extend the Label decorator to do what you'd like. :-)

> I'm a bit of a newb to Zend Framework, and this is deep enough inside
> the framework to make my head spin a bit, but it looks like a fairly
> simple addition. I'm just not sure how to execute it without breaking
> things further!  I realize that everyone's in a rush to get the last
> few changes in before the freeze, but I'd appreciate a hand with this
> if anyone has the time.

Code freeze is in around 100 minutes -- not going to make it in tonight.

There is documentation in the manual -- particularly if you're willing
to read the docbook XML currently in subversion (docbook is basically
human readable, so don't let it stop you) -- that shows how to create
plugins for the form classes, as well as how to substitute your own
classes for standard plugins. Extend the Label decorator with your own
Label decorator to do what you want. 

-- 
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


[fw-general] Is there a way to set options on a tag surrounding a label?

2008-03-07 Thread Karl Katzke
I'm using Zend_Form to build a form, and I'd like to align all of the labels
to the right inside their table cells. I can do this with either CSS or the
align="right" attribute of the table cell, but I would need to be able to
set attributes on the tag... which by my read, currently isn't possible.

Sample decorator:

 46 $this->setElementDecorators(array(
 47 'ViewHelper',
 48 'Errors',
 49
array('decorator'=>array('td'=>'HtmlTag'),'options'=>array('tag'=>'td')),
 50 array('Label',array('tag'=>'td')),
 51
array('decorator'=>array('tr'=>'HtmlTag'),'options'=>array('tag'=>'tr')),
 52 ));

In Zend_Form_Decorator_Label, we're already using
Zend_Form_Decorator_HtmlTag to render the tag option of the label. Could we
add a tagoptions field to that Label decorator and pass the array of options
through to the Zend_Form_Decorator_HtmlTag?

I'm a bit of a newb to Zend Framework, and this is deep enough inside the
framework to make my head spin a bit, but it looks like a fairly simple
addition. I'm just not sure how to execute it without breaking things
further! I realize that everyone's in a rush to get the last few changes in
before the freeze, but I'd appreciate a hand with this if anyone has the
time.

Thanks,
Karl Katzke