0
我有一個Symfony2應用程序,我試圖讓RESTful。以REST方式加載TWIG表單客戶端
,我無法弄清楚如何(如果它甚至有可能)- 創建使用
$form = $form->createView();
- 形式
我最大的問題,序列化
- 它傳遞給客戶
- 在客戶端解析它。
我正在使用FOS REST軟件包。
我可以在文檔 here中找到的是如何處理錯誤或渲染它。
如果是相關的,我現在用的是 JMS Serializer Bundle
下面的序列化的是,我傳遞到客戶端的JSON:我用FosRestbundle建立一個
{
"info": {
"ContactName": "Zane Zorn ",
"BusinessName": "Business 164",
"JobCategory": "House Sitting",
"MajorIntersection": "John St and Jane St",
"JobDescription": "A job that needs being done"
},
"form": {
"vars": {
"value": {},
"attr": [],
"id": "LeadResponseForm",
"name": "LeadResponseForm",
"full_name": "LeadResponseForm",
"disabled": false,
"multipart": false,
"block_prefixes": ["form", "LeadResponseForm", "_LeadResponseForm"],
"unique_block_prefix": "_LeadResponseForm",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm_LeadResponseForm",
"read_only": false,
"errors": [],
"valid": true,
"data": {},
"required": true,
"label_attr": [],
"compound": true,
"method": "POST",
"action": "",
"sonata_admin_enabled": false,
"sonata_admin": {
"edit": "standard",
"inline": "natural",
"block_name": false
}
},
"children": {
"ContactName": {
"vars": {
"value": "",
"attr": {
"value": "Zane Zorn "
},
"id": "LeadResponseForm_ContactName",
"name": "ContactName",
"full_name": "LeadResponseForm[ContactName]",
"disabled": false,
"label": "Contact Name",
"multipart": false,
"block_prefixes": ["form", "text", "_LeadResponseForm_ContactName"],
"unique_block_prefix": "_LeadResponseForm_ContactName",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm_ContactName_text",
"read_only": false,
"errors": [],
"valid": true,
"required": true,
"label_attr": [],
"compound": false,
"method": "POST",
"action": "",
"sonata_admin_enabled": false,
"sonata_admin": {
"edit": "standard",
"inline": "natural",
"block_name": false
}
},
"children": [],
"rendered": false
},
"Email": {
"vars": {
"value": "",
"attr": {
"value": "[email protected]"
},
"id": "LeadResponseForm_Email",
"name": "Email",
"full_name": "LeadResponseForm[Email]",
"disabled": false,
"label": "Your Email",
"multipart": false,
"block_prefixes": ["form", "text", "email", "_LeadResponseForm_Email"],
"unique_block_prefix": "_LeadResponseForm_Email",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm_Email_email",
"read_only": false,
"errors": [],
"valid": true,
"required": true,
"label_attr": [],
"compound": false,
"method": "POST",
"action": "",
"sonata_admin_enabled": false,
"sonata_admin": {
"edit": "standard",
"inline": "natural",
"block_name": false
}
},
"children": [],
"rendered": false
},
"Phone": {
"vars": {
"value": "",
"attr": {
"value": "(416)877-3344"
},
"id": "LeadResponseForm_Phone",
"name": "Phone",
"full_name": "LeadResponseForm[Phone]",
"disabled": false,
"label": "Your Phone",
"multipart": false,
"block_prefixes": ["form", "text", "_LeadResponseForm_Phone"],
"unique_block_prefix": "_LeadResponseForm_Phone",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm_Phone_text",
"read_only": false,
"errors": [],
"valid": true,
"required": true,
"label_attr": [],
"compound": false,
"method": "POST",
"action": "",
"sonata_admin_enabled": false,
"sonata_admin": {
"edit": "standard",
"inline": "natural",
"block_name": false
}
},
"children": [],
"rendered": false
},
"Message": {
"vars": {
"value": "",
"attr": {
"value": "It looks like your gonna need a new Johnson Rod. That's going to be 500$",
"style": "width:500px"
},
"id": "LeadResponseForm_Message",
"name": "Message",
"full_name": "LeadResponseForm[Message]",
"disabled": false,
"label": "The Message",
"multipart": false,
"block_prefixes": ["form", "text", "textarea", "_LeadResponseForm_Message"],
"unique_block_prefix": "_LeadResponseForm_Message",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm_Message_textarea",
"read_only": false,
"errors": [],
"valid": true,
"required": true,
"label_attr": [],
"compound": false,
"method": "POST",
"action": "",
"sonata_admin_enabled": false,
"sonata_admin": {
"edit": "standard",
"inline": "natural",
"block_name": false
}
},
"children": [],
"rendered": false
},
"Send to the Customer": {
"vars": {
"attr": [],
"id": "LeadResponseForm_Send to the Customer",
"name": "Send to the Customer",
"full_name": "LeadResponseForm[Send to the Customer]",
"disabled": false,
"multipart": false,
"block_prefixes": ["button", "submit", "_LeadResponseForm_Send to the Customer"],
"unique_block_prefix": "_LeadResponseForm_Send to the Customer",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm_Send to the Customer_submit",
"clicked": false
},
"children": [],
"rendered": false
},
"_token": {
"vars": {
"value": "b54d228db0acb06ed5686a6e3dbd7a231ec027e2",
"attr": [],
"id": "LeadResponseForm__token",
"name": "_token",
"full_name": "LeadResponseForm[_token]",
"disabled": false,
"multipart": false,
"block_prefixes": ["form", "hidden", "_LeadResponseForm__token"],
"unique_block_prefix": "_LeadResponseForm__token",
"translation_domain": "messages",
"cache_key": "_LeadResponseForm__token_hidden",
"read_only": false,
"errors": [],
"valid": true,
"data": "b54d228db0acb06ed5686a6e3dbd7a231ec027e2",
"required": false,
"label_attr": [],
"compound": false,
"method": "POST",
"action": "",
"sonata_admin_enabled": false,
"sonata_admin": {
"edit": "standard",
"inline": "natural",
"block_name": false
}
},
"children": [],
"rendered": false
}
},
"rendered": false
}
}