EDITED To Show Progress and Provide More Information
I have a collection that I am building from a join query that displays perfectly in Grid
and I now wish to have magento edit and save the data. I am aware I will need to write the updates separately, but will cross that when I get to it.
Additionally all tables are "flat" tables.
I am calling my collection on the form page using
$id = Mage::app()->getRequest()->getParam('id');
$model = Mage::getModel('folder1/folder2')->getCollection()->addFieldToFilter('main_table.id', array('eq' => $id))->allTables();
$form->setValues($model->getData());
allTables()
is in Collection.php
and looks something like this:
public function allTables() {
$select = $this->getSelect();
$select->joinLeft(
'joined_table',
'main_table.id = joined_table.id',
array('joined_val')
);
return $this;
}
This displays in the grid view perfectly and var_dump($model->getData())
shows all the data I'm expecting to see. When I press edit and try and populate my form it only displays the items in main_table
For instance:
$fieldset->addField('id', 'text', array(
'label' => Mage::helper('csm')->__('id'),
'name' => 'id',
'readonly' => 'true'
));
Shows the text field populated with the id but
$fieldset->addField('joined_val', 'text', array(
'label' => Mage::helper('csm')->__('Joined Val'),
'name' => 'joined_val'
));
Doesn't populate the field. Using joined_table.joined_val
doesn't seem to work.
Output of var_dump($model->getData())
array(1) {
[0]=>
array(24) {
["id"]=>
string(4) "1604"
//snip
["joined_val"]=>
string(2) "Plain text result to be shown"