formcollection

Can't persist symfony collection with double embedded form

◇◆丶佛笑我妖孽 提交于 2020-01-17 07:05:34
问题 I receive the following error when trying to submit my form : An exception occurred while executing 'INSERT INTO UserIngredientSupplier (quantity, cost, createdAt, updatedAt, unitId, organizationId, userIngredientId) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [1000, 4.5, "2014-11-27 22:46:51", "2014-11-27 22:46:51", 4, 2, null]: SQLSTATE[23000]: Integrity constraint violation: 1048 Le champ 'userIngredientId' ne peut être vide (null) I did not forget to put 'by_reference' => false , I did not

ASP.NET MVC2 - specific fields in form pass via a specific object?

非 Y 不嫁゛ 提交于 2020-01-15 09:42:21
问题 In database I have Contacts table: ContactID (int) FirstName (varchar) LastName (varchar) ... XmlFields (xml) // This field is xml type To create a new contact, I created two classes - one for regular fields and other to display fields from XmlFields field. In Controller, I have following: public ActionResult Create(Contact contact, FormCollection collection) ... Regular field I catch with contact object and those that need to be stored as xml in XmlFields I try to catch with collection

ASP.NET MVC2 - specific fields in form pass via a specific object?

亡梦爱人 提交于 2020-01-15 09:41:30
问题 In database I have Contacts table: ContactID (int) FirstName (varchar) LastName (varchar) ... XmlFields (xml) // This field is xml type To create a new contact, I created two classes - one for regular fields and other to display fields from XmlFields field. In Controller, I have following: public ActionResult Create(Contact contact, FormCollection collection) ... Regular field I catch with contact object and those that need to be stored as xml in XmlFields I try to catch with collection

how to convert formcollection to model in mvc

こ雲淡風輕ζ 提交于 2020-01-06 15:52:30
问题 Is it possible to convert formcollection to a 'model' known? [HttpPost] public ActionResult Settings(FormCollection fc) { var model=(Student)fc; // Error: Can't convert type 'FormCollection' to 'Student' } NOTE : for some reasons i can't use ViewModel instead. Here is my code VIEW: Settings.cshtml @model MediaLibrarySetting @{ ViewBag.Title = "Library Settings"; var extensions = (IQueryable<MediaLibrarySetting>)(ViewBag.Data); } @helper EntriForm(MediaLibrarySetting cmodel) { <form action='

asp.net-mvc get a dictionary in post action or how to transform FormCollection into a dictionary

▼魔方 西西 提交于 2019-12-21 14:34:51
问题 anybody knows how to transform the FormCollection into a IDictionary or how to get a IDictionary in the post action ? 回答1: This is just an equivalent of Omnu's code, but it seems more elegant to me: Dictionary<string, string> form = formCollection.AllKeys.ToDictionary(k => k, v => formCollection[v]); 回答2: I did it like this: var form = new Dictionary<string, string>(); foreach (var key in formCollection.AllKeys) { var value = formCollection[key]; form.Add(key, value); } 回答3: public static

What is correct behaviour of UpdateModel in ASP.NET MVC?

拜拜、爱过 提交于 2019-12-18 10:50:10
问题 I am interested to know what you guys feel should be deemed "correct behaviour" in terms of the UpdateModel method in ASP.NET MVC. The reason I ask here is perhaps if this functionality is "by design" somebody could clarify as to why it is the way it is, and perhaps a way to call it differently to achieve desired functionality, which I would imagine would be the way 90% of folk would want this to work? In essence, my gripe lies with the behaviour of the binding process within UpdateModel .

Submit javascript dynamically added elements to controller method like Stackoverflow

北慕城南 提交于 2019-12-12 21:10:56
问题 Put it simply: I'd like to let the user to select some tags in JS and submit it to my controller. Here are my suggestions: Create a hidden input for every inserted tag with naming convention like: Tag123 (123 = this tag's unique identifier) and iterate through FormCollection in my action method to find out which tags have been selected. Cons are obvious: using FormCollection instead of ViewModel and iterating through the FormCollection to get my desired data seems bad to me. Create one hidden

ZF2 Collection Validation

余生颓废 提交于 2019-12-11 23:29:38
问题 Is it possible to attach error messages to the Fieldset itself and not a child element in ZF2? I have a form with two Fieldsets and I need ensure the elements that are filled in Fieldset1 are also filled in Fieldset2. (There are optional elements inside each fieldset, but if Fieldset1->element1 is filled in, Fieldset2->element1 needs to be filled in). I have the validation working properly, but I receive an empty array when I call $form->getMessages() . The messages aren't being set inside

How to get formcollection using ajax.actionlink

你说的曾经没有我的故事 提交于 2019-12-11 16:13:42
问题 I have a controller with the codes like this: [AcceptVerbs("POST")] public ActionResult Create(FormCollection collection) { //why is that the collection is null? } I am calling this action using the ajax.actionlink. my problem is the collection is null, unlike if i use the submit(input) button the formcollection has values. 回答1: FormCollection has a default binder associated with it which always initializes the collection and you should never get null . It is more likely that you have an

checkboxes and radio buttons in MVC FormCollection

给你一囗甜甜゛ 提交于 2019-12-11 08:35:08
问题 I did some searching for determining which radio button is selected and if checkboxes are checked or not just using the FormCollection that is being passed to my Action method. For reasons I won't go into here, I can't use Html helpers so the auto adding of hidden fields is out for me. I did find someone that suggested using GetValue() on the collection object to determine which radio button is selected, but I can't seem to make that work as it is looking for a ValueProvider and I"m not sure