This is a migrated thread and some comments may be shown as answers.

RadioGroup Does Not Pass Value To Post

1 Answer 412 Views
RadioGroup
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Apr 2021, 05:02 PM

I'm using the RadioGroup and setting the for to a string property in my page model.  The Get is working fine with displaying the value in the model but when I save the form, in the post the for value is null.  Any ideas on how to get this to work?

Razor Page

<kendo-radiogroup for="Input.OwnOrRentId"
    label-position="RadioGroupLabelPosition.Before"
    layout="RadioGroupLayout.Horizontal" bind-to="Model.OwnOrRentItems">
</kendo-radiogroup>

 

Code behind

  [BindProperty]
   public InstallerPageModel Input { get; set; }

 

 public List<IInputGroupItem> OwnOrRentItems { get; set; }
 
        OwnOrRentItems = new List<IInputGroupItem>()
        {
            new InputGroupItemModel()
            {
                Label = OwnOrRentOptions.Own.GetDescription(),
                Value = OwnOrRentOptions.Own.NumericValue().ToString(),
                Enabled = true,
                CssClass = "green",
                Encoded = false,
                HtmlAttributes = new Dictionary<string,object>() { { "data-custom", "custom" } }
            },
            new InputGroupItemModel()
            {
                Label = OwnOrRentOptions.Rent.GetDescription(),
                Value = OwnOrRentOptions.Rent.NumericValue().ToString(),
                Enabled = true,
                CssClass = "green",
                Encoded = false,
                HtmlAttributes = new Dictionary<string,object>() { { "data-custom", "custom" } }                   
            }
        };
 
   public class InputGroupItemModel :IInputGroupItem
   {
    public IDictionary<string, object> HtmlAttributes { get; set; }
 
    public string CssClass { get; set; }
 
    public bool? Enabled { get; set; }
 
    public bool? Encoded { get; set; }
 
    public string Label { get; set; }
 
    public string Value { get; set; }
   }

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 23 Apr 2021, 10:36 AM

Hi John,

Thank you for bringing this issue to our attention.

For nested properties, the RadioGroup tag helper generates the name of its inputs with a lower dash (_), while it should generate those with a dot (.). Having that said, the value chosen is not properly passed to the page model. Here is a GitHub issue I have opened on the above:

https://github.com/telerik/kendo-ui-core/issues/6389

As a small token of gratitude for reporting the above, I have updated your Telerik points.

As a temporary workaround, you could manually set the input-name value of the Tag helper:

<kendo-radiogroup for="Input.OwnOrRentId"
				  label-position="RadioGroupLabelPosition.Before"
				  layout="RadioGroupLayout.Horizontal" bind-to="Model.OwnOrRentItems"
				  input-name="Input.OwnOrRentId">
</kendo-radiogroup>

Regards,
Veselin Tsvetanov
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
RadioGroup
Asked by
John
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or