Ello,
isValid() also throws a notice if there's no validator for a certain
element.
The setDefaults() method in Zend_Form_Abstract is also a little bogus:
public function setDefaults(array $defaults)
{
foreach ($defaults as $key => $value) {
if (isset($this->[$key])) {
$this[$key]->setValue($value);
}
}
return $this;
}
Should be:
public function setDefaults(array $defaults)
{
foreach ($defaults as $key => $value) {
if (isset($this->_elements[$key])) {
$this->_elements[$key]->setValue($value);
}
}
return $this;
}
But that's just detail :)
Andries Seutens
http://andries.systray.be
Matthew Weier O'Phinney schreef:
-- Simon Mundy <[EMAIL PROTECTED]> wrote
(on Monday, 07 January 2008, 04:25 PM +1100):
I've had a play with Zend_Form - using Andries Seutens example as a starting
point.
Does this look like the correct (read 'efficient'!) way you had intended the
form to be populated/processed? It's not quite clear on the proposal - if I
call the isValid() method on a form with an array of values, they don't
actually save their values to each element (is that intended?).
No, unintended -- isValid($data) should also populate. I'll make a note
to make a test for that use case.
<snip>
I've also 'hacked' in some functionality to allow multidimensional arrays
within element names. So you can have:-
myelement
myelement[key]
myelement[foo][bar] ..etc...
Hope this comes in handy - here's the diffs (I imagine you'd probably want to
write a new separate inflector for these, but it's a start):-
Excellent -- thanks! That's a use case that several have requested.
Gecontroleerd op virussen door de JOJO Secure Gateway.