得到基於關閉的一個解決方案:https://www.silverstripe.org/community/forums/form-questions/show/24628
我做的是這樣的方式:
SS模板
$("table.myTable").on('change','select#Some_Form',function(){
$.ajax({
type: "POST",
data: {param:param},
url: window.location.href+"your_action_here",
success: function(result) {
var resArr = JSON.parse(result);
$('input#Some_Field').val(resArr['key']);
}
});
});
控制器
static $allowed_actions = array('your_action_here');
//parameter is a SS_HTTPRequest
public function your_action_here($request){
//assuming my parameter is an ID
$ID = $request['param'];
$dataObject = DataObject::get_by_id('Object',$ID);
$JSONArray = array('key'=>$dataObject->Field);
echo json_encode($JSONArray);
}
當選擇的變化,得到DataObject
和正確填充:)
應該在這裏足夠的信息來複制... https://github.com/sheadawson/ silverstripe-dependentdropdownfield(而不是另一個下拉菜單,你正在填充一個div或其他東西......) – Barry