I would like a Zend_Form object to be output as essentially
array('name' => 'input username in db', 'description' => 'description thats in the database');
so far If I do
print_r((array) $form);
I get:
{"\u0000*\u0000_attribs":{"name":"add","enctype":"multipart\/form-data","method":"post"},"\u0000*\u0000_decorators":{"FormElements":{"decorator":"FormElements","options":null},"HtmlTag":{"decorator":"HtmlTag","options":{"tag":"dl","class":"zend_form"}},"Form":{"decorator":"Form","options":null}},"\u0000*\u0000_defaultDisplayGroupClass":"Zend_Form_DisplayGroup","\u0000*\u0000_description":null,"\u0000*\u0000_disableLoadDefaultDecorators":false,"\u0000*\u0000_displayGroupPrefixPaths":[],"\u0000*\u0000_displayGroups":[],"\u0000*\u0000_elementDecorators":null,"\u0000*\u0000_elementPrefixPaths":[],"\u0000*\u0000_elements":{"name":{"helper":"formText"},"name_url":{"helper":"formText"},"description":{"helper":"formTextarea","rows":"10"}
etcetc, alot of Zend storage
If I do:
$form = new Form_Administration_Movie_Add();
$elements = $form->getElements();
foreach($elements as $key => $element)开发者_JAVA百科 {
echo $key;
}
I get a list of the fields, however I cannot do $element->getValue() as I just get 0 or 1 and no the actual data.
Ideas?
$array = $form->getValues();
Does this work? :)
Edit: You might need to use either $form->isValid($_POST)
or $form->populate($_POST)
before calling the getValues()
method.
精彩评论