[CLOSED] Combo box marks itself as required

  1. #1

    [CLOSED] Combo box marks itself as required

    I have a combo box defined as:
    X.ComboBoxFor(m => m.GLOBAL_TAX_CODE).FieldLabel("Tax Code").LabelWidth(80).DisplayField("ComboDisplay").ValueField("TaxCodeID")
            .ListConfig(Html.X().BoundList()
                            .ItemTpl(Html.X().XTemplate()
                                .Html(@<text>
                                <div class="list-item">
                                    <h3>{Name} - Rate: {RATE}%</h3>   
                                    {DESCRIPTION}                                                                                                   
                                </div>
                                </text>)
                                )
                        )
            .Store(X.Store()
            .ID("TaxCodeComboStore")
            .AutoLoad(true)
            .Model(
                    X.Model()
                    .Name("TaxCodeCombo")
                    .IDProperty("TaxCodeID")
                    .Fields(
                        X.ModelField()
                            .Name("Name")
                            .Type(ModelFieldType.String),
                        X.ModelField()
                            .Name("DESCRIPTION")
                            .Type(ModelFieldType.String),
                        X.ModelField()
                            .Name("RATE")
                            .Type(ModelFieldType.Float)
                    )
                )
            .Proxy(Html.X().AjaxProxy()
                .Url(Url.Action("GetList", "List", new { area = "TaxCode" }))
                .Reader(Html.X().JsonReader().Root("data"))
                )
            )
    The model property is not marked as Required.
    Yet, when I focus on the field and leave it becomes red and the message says it is a required field.
    Where is this required condition coming from if I am not defining it specifically for this field?

    Thank you
    Last edited by Daniil; Apr 02, 2015 at 11:02 AM. Reason: [CLOSED]
  2. #2
    Hi @registrator,

    Please post a definition of the m.GLOBAL_TAX_CODE property.
  3. #3
            [DisplayName("Global tax code")]
            [Range(0, 99, ErrorMessage = "Value must be maximum 2 characters")]
            public int GLOBAL_TAX_CODE { get; set; }
  4. #4
    Thanks.

    "int" is not a Nullable type. By default, it is treated like there must be a value. So, a ComboBox's AllowBlank turns to false by default.

    You can set .AllowBlank(true) explicitly.
  5. #5
    Thank you.

Similar Threads

  1. [CLOSED] Fill Combo-box store client side based on another Combo-box selection
    By speedstepmem4 in forum 3.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 12, 2015, 5:21 AM
  2. [CLOSED] Form should work with url which has quotation marks
    By macroe in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: May 28, 2014, 5:15 AM
  3. [CLOSED] Required/Not Required Text Fields Alignment - FormPanel
    By Istofix in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Mar 04, 2014, 12:50 PM
  4. Replies: 6
    Last Post: Aug 25, 2011, 2:13 PM
  5. Replies: 1
    Last Post: Jan 13, 2010, 11:36 AM

Posting Permissions