Zend Framework: Fill form with data from mapper
There is an example of getting data **from form** using mapper in official [quickstart][1]. But there is no example in the whole Internet of **populating form** with data **from mapper** (for usual edit action, for example).

I usually do something like this (without using mapper and dbTable):

    class News_Model_Form_News extends Zend_Form {
	
	private $id = 0;
	
	public function getId(){
		return $this->id;
	}
	
	public function setId($id){
		$this->id = $id;
	}
	
	public function init() {
		
        $model = new News_Model_Backend();
		        
		//if form is needed for adding action
		if (!$this->id) {
			//form code
		} else {
		//if form is needed for edit action (fill with values)
			//form code with values
		}
    }}


But with mapper pattern this stuff should became more elegent and cool, but I don't know how to do this.

So the question is how to populate form with values using mapper pattern (for edit guestbook entry from quickstart, for example)?


  [1]: http://framework.zend.com/manual/en/learning.quickstart.create-form.html
Zend Framework: Fill form with data from mapper
===

There is an example of getting data **from form** using mapper in official [quickstart][1]. But there is no example in the whole Internet of **populating form** with data **from mapper** (for usual edit action, for example).

I usually do something like this (without using mapper and dbTable):

    class News_Model_Form_News extends Zend_Form {
	
	private $id = 0;
	
	public function getId(){
		return $this->id;
	}
	
	public function setId($id){
		$this->id = $id;
	}
	
	public function init() {
		
        $model = new News_Model_Backend();
		        
		//if form is needed for adding action
		if (!$this->id) {
			//form code
		} else {
		//if form is needed for edit action (fill with values)
			//form code with values
		}
    }}


But with mapper pattern this stuff should became more elegent and cool, but I don't know how to do this.

So the question is how to populate form with values using mapper pattern (for edit guestbook entry from quickstart, for example)?


  [1]: http://framework.zend.com/manual/en/learning.quickstart.create-form.html