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. 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?

Thanks,
Bradley

-- 
Bradley Holt
[EMAIL PROTECTED]

Reply via email to