Form helper 'descr' implemented (was Re: [Solar-talk] Another form question)

Antti Holvikari anttih at gmail.com
Sat Dec 1 09:39:00 CST 2007


On Nov 29, 2007 7:00 PM, Antti Holvikari <anttih at gmail.com> wrote:
>
> On Nov 26, 2007 4:09 AM, Paul M Jones <pmjones at solarphp.com> wrote:
> > On 21 Nov 2007, at 11:49, Rodrigo Moraes wrote:
> >
> > > On Nov 21, 2007 2:10 PM, Oscar wrote:
> > >> Paul M Jones wrote:
> > >>> On Nov 21, 2007, at 9:40 AM, Oscar wrote:
> > >>>
> > >>> Sounds like it's time to make this "real".  ;-)  For
> > >>> Solar_View_Helper_Form, then:
> > >>>
> > >>> * Add a $_descr_tag property and config, default value 'div' (but
> > >>> you
> > >>> can make it 'p').  This is the tag that goes around the
> > >>> description XHTML.
> > >>>
> > >>> * Add a $_descr_class property and config, default value
> > >>> 'descr' (for
> > >>> the class so you can style it).
> > >>>
> > >>> * Add a $_descr_elem property and config, default value 'dt' (to say
> > >>> where the description should be rendered, as part of the 'dd' or
> > >>> as part
> > >>> of the 'dt' element).
> > >>>
> > >>> And then add the necessary rendering logic as you guys have done.
> > >>>
> > >>> Does that sound sufficiently useful and flexible?  (I don't want it
> > >>> *too* flexible -- too many options can be a bad thing.)
> > >>>
> > >> Looks more than flexible enough to me.
> > >
> > > Yes, sounds fine to me too. I really don't mind about which tag is
> > > used, if you would ask me. I would adapt the CSS rule for the one that
> > > is used. Also, for me it could be placed inside dd or dt, as far as it
> > > is displayed "somewhere". Really, but it is nice to have this option.
> > > :)
> >
> > At long long last, this is implemented in SVN, as of revision 2956.
> > Let me know how it works for you guys.
>
> Suddenly I see DESCR_* texts everywhere in my forms. I think it would
> make sense to only show the 'descr' text if there is something. Like,
> check to see if it is != "DESCR_{$element_name}", and only then
> display??

Ok, here's a patch. Only create a descr element if 'descr' is truthy
*and* the descr string doesn't start with 'DESCR_'. Any better ideas?

Btw, the reason why there are 'DESC_*' all over is that model form
loader adds them, otherwise it's not a problem.

--- a/Solar/View/Helper/Form.php
+++ b/Solar/View/Helper/Form.php
@@ -605,7 +605,7 @@ class Solar_View_Helper_Form extends Solar_View_Helper {
                 // get the element description
                 $dt_descr = '';
                 $dd_descr = '';
-                if ($info['descr']) {
+                if ($info['descr'] && substr($info['descr'], 0, 6) !=
'DESCR_') {

                     // build the base description.
                     // open the tag ...


-- 
Antti Holvikari


More information about the Solar-talk mailing list