私は@Davidのアプローチに完全に同意し、同じことを記念して、このスケルトンコードを投稿します:
sampleview.phtml
echo '<div id="a">'.$this->form.'</div>';
<?php $this->jQuery()->onLoadCaptureStart(); ?>
jQuery('#category').change(checkNumberExistsAction);
<?php $this->jQuery()->onLoadCaptureEnd(); ?>
<script type="text/javascript">
function checkNumberExistsAction(){
var p = $("#idOfNumberField").val();
var response = $.ajax({
url: "<?php echo $this->url(array('controller'=>'index',
'action'=>'sampleview')) ?>",
type: "GET",
data: {number: p}, //where number is number columnName in database
cache: false,
success: function(text){
response = text;
$("#name").val($(text).find("input[name='name']").val()); //where name is id of name field
$("#name").attr("disabled", "disabled");
$("#firstName").val($(text).find("input[name='firstName']").val()); //where firstName is id of first name field
$("#firstName").attr("disabled", "disabled");
},
error: function(){ alert('Something went wrong.'); }
});
}
</script>
IndexController.php
public function sampleviewAction(){
if ($this->getRequest()->isXmlHttpRequest()){
$id = $this->_getParam('number', 0);
if ($id > 0){
$albums = new Application_Model_DbTable_Albums();
$form->populate($albums->getAlbum($id));}
}
}
Modelsampleview.php
public function getAlbum($id){
$id = (int)$id;
$row = $this->fetchRow('e_recNo = ' . $id);
if (!$row){
throw new Exception("Could not find row $id");
}
return $row->toArray();
}