Hello everyone,
when i create a model, that has 1:n-relations, it could be possible that the CRUD-Generator generates a preview of the child entries; for example:
List Post:
1: Post Nr. 1
Title: xxx
Contains 2 Comments:
* 1: …
* 2: …
2: Post Nr. 2
Title: xxx
Contains 0 Comments.
and so on.
At the moment, i have to manually adjust the generated files, something like this (for action "show"):
ObjectController.php
<?php
public function actionShow()
{
$customer = $this->loadCustomer();
$objects = $customer->objects; // <-- retrieve foreign key objects
$this->render('show',array('objects' => $objects, 'model'=>$customer)); // <-- pass them to the view
}
?>
<?php
This Customer owns the following Objects:
<ul>
<?php foreach($objects as $object) {
echo "<li> Nr: " . $object->objectid . "/". $object->name . "</li>";
}
?>
</ul>
?>
Does it make sense to automate this behaviour in the CRUD-Generator? I think, it could save a lot of work when dealing with a lot of relations. There is a lot of Information in the model, that could be used to generate much-nicer Default views?