You are not logged in.
A helpful screencast, but I have some questions with regards to the adding of elements to the form:
When you're adding the elements to the form, you add all of them except the submit button, I tried adding the submit button and it appears twice on my form. Why does this happen? How does Zend_Form know to add this element without telling it to?
I removed the addition of elements code ($this->addElements(array( ... ));) from my script, yet the elements were still rendered on the form, are they being picked up somewhere else? The documentation insists that you have to add the elements to the form, but mine appear to be added fine without telling it to...
Many thanks.
Offline
It has since been pointed out to me that Zend_Form utilises the __get and __set methods to automatically pick them up.
Offline
Hi zend's guru!
Facts:
Controller: ItemController
Action: indexAction:
...
public function indexAction()
{
$item1 = new App_ItemDto('item 1', 'hello world', 1);
$item2 = new App_ItemDto('item 2', 'hello world', 2);
$item3 = new App_ItemDto('item 3', 'hello world', 3);
$this->view->items = array($item1, $item2, $item3);
print_r($this->view->items);
}
...
This code returns result:
Array ( [0] => App_ItemDto Object ( [name] => [description] => [id] => ) [1] => App_ItemDto Object ( [name] => [description] => [id] => ) [2] => App_ItemDto Object ( [name] => [description] => [id] => ) )
What wrong? Anybody have any ideas?
Thanks and regards.
Alex
PS: my App_ItemDto is:
class App_ItemDto {
public $name;
public $description;
public $id;
public function _construct($name, $description, $id)
{
$this->name = $name;
$this->description = $description;
$this->id = $id;
}
Offline