Matthew,
Great - thanks for the help!
On Sun, Sep 7, 2008 at 9:44 PM, Matthew Weier O'Phinney <[EMAIL
PROTECTED]>wrote:
> -- Bradley Holt <[EMAIL PROTECTED]> wrote
> (on Sunday, 07 September 2008, 08:35 PM -0400):
> > It appears that dash characters are not allowed in Zend_Form_Element
> names. For
> > example, I create the following element:
> >
> > $someParameterElement = new Zend_Form_Element_Text('some-parameter');
> >
> > When I render the form that the element is in I lose the dashes:
> >
> > <input type="text" name="someparameter" id="someparameter" value="" />
> >
> > What I had hoped for was:
> >
> > <input type="text" name="some-parameter" id="some-parameter" value="" />
> >
> > Trying to set the name attribute doesn't help either:
> >
> > $someParameterElement->setAttrib('name', 'some-parameter');
> >
> > I'm using inflection to get these parameters into a database so the dash
> > character is important. I could use underscores (or some other separator
> that
> > is allowed) but dashes seem to be the convention in Zend Framework for
> word
> > separators in parameters and I was trying to stick to that convention
> (also, we
> > use dash-separated-words for CSS selectors so the name would be
> inconsistent
> > with the id). This would create inconsistencies in how a deal with
> parameters
> > in the application. For example, say I have the following URL for
> retrieving
> > data based on the some-parameter parameter:
> >
> >
> http://www.example.org/some-controller/some-action/some-parameter/some-value/
> >
> > Here I'm following Zend Framework's dash-word-separator convention for
> the
> > parameter name. This would mean I'd have to inflect the parameter names
> > differently depending on whether I'm reading (dashes) or
> inserting/updating
> > (underscores) data.
>
> Element names must be valid PHP variable names, plain and simple. This was
> to allow referring naming variables after the element names as well as
> to allow overloading to retrieve elements from a form. Additionally,
> doing so ensures that the names will work with most configuration
> formats.
>
> You can override this behavior by extending Zend_Form; remove the
> overloading and override setName() to do it.
>
> > Alternatively I could break the dash-separator convention and simply
> > go with:
> >
> >
> http://www.example.org/some-controller/some-action/some_parameter/some-value/
> >
> > This would allow me to use the parameter name inflection consistently but
> I'd
> > really like to stick with dashes for several reasons - convention, SEO,
> plus I
> > think they look better ;-)
> >
> > Given the choice, I'll probably just inflect the parameter names
> differently
> > based on whether I'm reading or inserting/updating rather than lose my
> pretty
> > URLs. Am I just missing how to do this or does Zend_Form not allow it?
>
> --
> Matthew Weier O'Phinney
> Software Architect | [EMAIL PROTECTED]
> Zend Framework | http://framework.zend.com/
>
--
Bradley Holt
[EMAIL PROTECTED]