<!DOCTYPE html> <html lang="en"> <head> {include file="public/head" /} </head> <body style="padding:10px"> <form id="form1"> </form> <textarea id="spec_item_text">{$data.spec_item}</textarea> <script type="text/javascript"> var fields=[ { display: "规格编码", name: "spec_code", newline: true,validate: { required: true}, type: "text"}, { display: "规格名称", name: "spec_title", newline: true,validate: { required: true}, type: "text"}, { display: "所属模型", name: "model_id", newline: true,validate: { required: true}, type: "popup", editor:{ condition: { fields: [{ name: 'title', label: '产品名称' }] }, grid: { columns: [ {width:160, display: '商品模型编码', name: 'code'}, {width:160, display: '商品模型名称', name: 'title'} ], url: "{:url('admin/GoodsModel/search')}", pageSize: 10, isSingleCheck:true }, valueField: 'model_id', textField: 'code', width: 180 } }, { display: "规格项", name: "spec_item", newline: true,validate: { required: true}, type: "textarea" }, { display: "排序", name: "sort", newline: true,validate: { required: true}, type: "int"} ]; $(function () { //创建表单结构 $.metadata.setType("attr", "validate"); $("#form1").ligerForm({ validate: true, inputWidth: 170, labelWidth: 90, space: 40, fields: fields }); var form = liger.get("form1"); form.setData({ sort: '{$data.sort}', spec_code: '{$data.spec_code}', spec_title: '{$data.spec_title}', model_id: '{$data.model_id}', spec_item:$("#spec_item_text").val() }); liger.get("model_id").setText("{$data.title}"); }); function submitForm() { var form = liger.get("form1"); var data = form.getData(); if(form.valid()){ callajax('{:url("admin/GoodsSpec/save")}','post',data,function (data) { return data; }); } if (!form.valid()) { form.showInvalid(); return; } } </script> </body> </html>