Maybe this solution already exists but needed a fast way to implement, so the only thing to add is on the template (on the example offices.php) add at the end:
<?php
echo <<<EOT
<script>$(document).ready(function() {
EOT;
if(isset($selectDefault)){
foreach ($selectDefault as $key => $value) {
echo <<<EOT
document.getElementById("$key").value = '$value';
$("#$key").trigger("liszt:updated");
EOT;
}
}
if(isset($textDefault)){
foreach ($textDefault as $key => $value) {
echo <<<EOT
document.getElementById("$key").value = '$value';
EOT;
}
}
echo "});";
echo "</script>";
?>
And on the controller
just add:
$output = $crud->render();
//For input text:
$output->textDefault=array("field-name"=>$value);
//For input select:
$output->selectDefault=array("field-state"=>'COMPLETE');
$this->_example_output($output);
the array key is the id of the field that is "field-"+ field name.
Hope it is clear enough.
