是否有可能將formcollection轉換爲已知的「模型」? [HttpPost]
public ActionResult Settings(FormCollection fc)
{
var model=(Student)fc; // Error: Can't convert type 'FormCollection' to 'Student'
}
注
我有一個實體叫'候選人'。這不是那麼特別。它本身就很好:我可以從一個類型創建一個表單並堅持它。 class CandidateType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name
我收到以下錯誤An unhandled exception occurred while processing the request. InvalidOperationException: The 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinder' cannot bind to a model of