嗯,目前我有这样的事情:
我想在过滤器之前添加类别,例如:
我的表单代码:
[HttpPost]
public ActionResult ExchangeToken(string public_token)
{
var client = new RestClient("https://development.plaid.com/item/public_token/exchange");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "c4c60478-e5c2-3ef7-5b3f-74a1d6ab871c");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n\t\"client_id\" : \"xxxxx\",\n\t\"public_token\" : \"" + public_token + "\",\n\t\"secret\" : \"xxxxxx\"\n}", ParameterType.RequestBody);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
IRestResponse response = client.Execute(request);
var content = response.Content;
JToken token = JObject.Parse(content);
var access_token = token.SelectToken("access_token").ToString();
var item_id = token.SelectToken("item_id").ToString();
//----------------------------------------------------------------------------------------------
var client2 = new RestClient("https://development.plaid.com/transactions/get");
var request2 = new RestRequest(Method.POST);
request2.AddHeader("postman-token", "e55586a7-dc79-e4a8-6f1f-ac2d7030c582");
request2.AddHeader("cache-control", "no-cache");
request2.AddHeader("content-type", "application/json");
request2.AddParameter("application/json", "{\n\t\"client_id\" : \"xxxxxxx\",\n\t\"secret\" : \"xxxxxxxxx\",\n\t\"access_token\" : \"" + access_token + "\",\n\t\"start_date\" : \"2017-01-01\",\n\t\"end_date\" : \"2017-07-07\"\n}", ParameterType.RequestBody);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
IRestResponse response2 = client2.Execute(request2);
var content2 = response2.Content;
JToken token2 = JObject.Parse(content2);
var transactions = token2.SelectToken("transactions").ToString();
return PartialView("Index", transactions);
}
如何在之前添加类别?
感谢您的帮助:)。
修改:
我终于在twig视图中成功了(但也需要在控制器中让group by):
$formFilter = $this->createFormBuilder()
->add('_', EntityType::class,array(
'class' => 'loicFilterBundle:Filter',
'multiple' => true,
'expanded' => true,
'choice_label' => function($value) {
return ($value->getName());
},
))
->add('Appliquer filtres', SubmitType::class)
->getForm();
答案 0 :(得分:0)
使用group_by
选项(see doc)怎么样?
类似的东西:
$formFilter = $this->createFormBuilder()
->add('_', EntityType::class,array(
'class' => 'loicFilterBundle:Filter',
'multiple' => true,
'expanded' => true,
'choice_label' => function($value) {
return $value->getName();
},
'group_by' => function($value) {
return $value->getCategory()->getName();
},
))
->add('Appliquer filtres', SubmitType::class)
->getForm();