[CLOSED] Submit form in the model has a list of objects.

  1. #1

    [CLOSED] Submit form in the model has a list of objects.

    Hello good.

    I have a problem when doing a submit form in the model has a list of objects.

    model
    
       [Model(Name = "ReviewAll")]
        public class ReviewAll
        {
            [ModelField(IDProperty = true, UseNull = true)]
            [Field(Ignore = true)]
            public int? ReviewID
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public string Registration
            {
                get;
                set;
            }
    
            public List<Wheel> Whell
            {
                get;
                set;
            }
        }
    
        [Model(Name = "Wheel")]
        public class Wheel
        {
            [ModelField(IDProperty = true, UseNull = true)]
            [Field(Ignore = true)]
            public int? WheelID
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public int ReviewID
            {
                get;
                set;
            }
    
            public int Axis
            {
                get;
                set;
            }
    
            public int Index
            {
                get;
                set;
            }
    
        }
    controller
    
        public ActionResult RenderView()
            {
                try
                {
                    ReviewAll ra = new ReviewAll();
                    
                    List<Wheel> w = new List<Wheel>();
    
                    for (int i = 0; i <= 3; i++)
                    {
                        Wheel one = new Wheel();
                        one.Axis = i;
                        one.Index = i;
                        w.Add(one);
                    }
    
                    ra.Registration = "test";
                    ra.Whell = w;
    
                    return View(ra);
                }
                catch
                {
                    
                }
            }
    
     public ActionResult SuccessSubmit(ReviewAll person)
            {
                X.Msg.Alert("Submit", JSON.Serialize(person)).Show();
                return this.FormPanel(true);
            }
    view

    
    @model Euromaster.Models.ReviewAll
    
    /*
    ...
    */
    
    
    X.NumberFieldFor<int>(m => m.Whell[0].Axis).FieldLabel("Axis")
    X.NumberFieldFor<int>(m => m.Whell[1].Axis).FieldLabel("Axis")
    X.NumberFieldFor<int>(m => m.Whell[2].Axis).FieldLabel("Axis")
    When I do submit, Whell this to null

    What am I doing wrong ??

    As I can fix ??

    Thank you very much and greetings !!
    Last edited by Daniil; Oct 31, 2014 at 11:31 AM. Reason: [CLOSED]
  2. #2
    Hi @threewonders,

    This throws an Exception for me.
    X.NumberFieldFor<int>(m => m.Whell[0].Axis).FieldLabel("Axis")
    I had to remove <int>.

    The RenderView controller action also throws a compile error.

    Also you don't post a full view and I don't see how you submit the values from client side.

    Ideally, we would love to have something that we can copy, paste and run without any changes (or very minor ones like renaming the namespace of the Model class). Almost all other cases leaves a lot of space for guesswork.

    So, I guess the values are just not submitted to server in your case.

    I just tried your code with this View and it works well.
    @model Work2MVC.Controllers.ReviewAll
    @{
        var X = Html.X(); 
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>
    </head>
    <body>
        <form>
            @X.ResourceManager()
    
            @X.NumberFieldFor(m => m.Whell[0].Axis).FieldLabel("Axis")
            @X.NumberFieldFor(m => m.Whell[1].Axis).FieldLabel("Axis")
            @X.NumberFieldFor(m => m.Whell[2].Axis).FieldLabel("Axis")
    
            @X.Button().Text("Submit").DirectClickAction("SuccessSubmit")
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 1
    Last Post: Jul 30, 2013, 3:36 PM
  2. [CLOSED] Allow Users To Order a List of [Objects]
    By garrisrd in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 18, 2011, 3:11 PM
  3. aligning form objects
    By craig2005 in forum 1.x Help
    Replies: 2
    Last Post: Jan 06, 2011, 3:25 AM
  4. [CLOSED] How to place list objects in server mapping
    By sriram in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 16, 2010, 5:28 AM
  5. [CLOSED] Submit gridpanel data in form submit
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 14, 2010, 7:25 PM

Posting Permissions