I searched and tested different solutions the whole Sunday and can't find any that works propartly. And in my eyes I have really follow the solution sources.
I have a CRUD form - this one is for update.
And I want to populate the row value from that ID into the form, but keep get error:
Catchable fatal error: Argument 1 passed to Zend_Form::populate() must be an array, object given
The MVC structures is like the quickstart guestbook, with Datamapper and DBTable-files.
| Code: |
public function find($id)
{
$this->getMapper()->find($id, $this);
return $this;
}
|
| Code: |
public function find($id, Admin_Model_NewsArchive $NewsArchive) {
$table = $this->getDbTable();
$row = $table->fetchRow($table->id);
$NewsArchive->setId($row->id)
->setTitle($row->title)
->setIntro($row->intro)
->setMainContent($row->maincontent)
->setMetatitle($row->meta_title)
->setDatepub($row->date_pub);
// Get the column/value associative array from the Row object
return $rowArray = $row->toArray();
}
|
| Code: |
$model = new Admin_Model_NewsArchive();
print_r($model->find($id));
$form->populate($model->find($id));
|
When I print_r the value I acctually get the first row
"Admin_Model_NewsArchive Object ( [_intro:protected] => test [_datepub:protected] => 2010-01-03 12:19:06 [_pubstatus:protected] => [_title:protected] => Nyhet [_maincontent:protected] =>sds
[_metatitle:protected] => [_metakeys:protected] => [_metadesc:protected] => [_mainimage:protected] => [_mainimagetype:protected] => [_lang:protected] => [_id:protected] => 364"
But after that it also write alot of other array-data, like the mysql username, password and everything from the config file?