Completed
Last Updated: 04 Apr 2024 15:40 by Chris
Release 4.2.0 (04/26/2023)
Stewart
Created on: 16 Mar 2023 09:14
Category: Form
Type: Bug Report
19
Form reorders items and custom markup

When I updated to the latest version I noticed that the FormItems in AuthorizedViews were moved to the bottom of the form, Quick example:

<TelerikForm>
    <FormItems>
        <AuthorizeView>
            <Authorized>
                <FormItem Field="First"/>
            </Authorized>
        </AuthorizeView>
        <FormItem Field="Second"/>
    </FormItems>
</TelerikForm>

will end up like

<TelerikForm>
    <FormItems>
        <FormItem Field="Second"/>
        <FormItem Field="First"/>
    </FormItems>
</TelerikForm>

16 comments
Chris
Posted on: 04 Apr 2024 15:40

Hi Dimo

I'm already using FormGroup with columns (plus I don't need the headers etc that come with a group) - my issue is that it's a lot of extra work and complexity to add custom formatting in where required when trying to use the offered solution.  Your example wouldn't work because I want to render like so (intermix custom formatting with normal FormItem components in a flexible layout):

<FormGroup Label="Main">

<FormItem Field="A" />

<FormItem Field="B"/>

<FormItemCustomTemplate>

    <div class="myLayout">

        <FormItem Field="C" />

        <FormItem Field="D" />

    </div>

</FormItemCustomTemplate>

<FormItem Field="E" />

</FormGroup>

 

Is this at all possible??  All I want to do is have the option to include a generic component (that has no layout or formatting applied) but is allowed within a FormItems tag and gives me the option to define anything inside it (just like I do now).

Having to jump between FormItems & FormItemsTemplate and then use a TelerikFormItemRenderer is a very long-winded (and complicated) way of achieving the same result, whereas at least with my option there is no need to define a context etc, it's just a component tag that allows me to do what I do now, just within a special area.

ADMIN
Dimo
Posted on: 04 Apr 2024 15:10

Hi Chris,

If you only need two form items side by side, then it's a lot simpler to use a Form Group with Columns="2".

@using System.ComponentModel.DataAnnotations

<TelerikForm Model="@person">
    <FormValidation>
        <DataAnnotationsValidator></DataAnnotationsValidator>
    </FormValidation>
    <FormItems>
        <FormGroup LabelText="Personal Information">
            <FormItem LabelText="First Name" Field="@nameof(Person.FirstName)"></FormItem>
            <FormItem LabelText="Last Name" Field="@nameof(Person.LastName)"></FormItem>
            <FormItem LabelText="Age" Field="@nameof(Person.Age)" ColSpan="2"></FormItem>
            <FormItem LabelText="Email" Field="@nameof(Person.Email)" ColSpan="2"></FormItem>
        </FormGroup>
        <FormGroup LabelText="Employee Information" Columns="2" ColumnSpacing="25px">
            <FormItem LabelText="Company Name" Field="@nameof(Person.CompanyName)"></FormItem>
            <FormItem LabelText="Position" Field="@nameof(Person.Position)"></FormItem>
        </FormGroup>
    </FormItems>
</TelerikForm>

@code {
    public Person person { get; set; } = new Person();

    public class Person
    {
        [Required(ErrorMessage = "The First name is required")]
        public string FirstName { get; set; }
        [Required(ErrorMessage = "The Last name is required")]
        public string LastName { get; set; }
        [Range(18, 120, ErrorMessage = "The age should be between 18 and 120")]
        public int Age { get; set; }
        [Required]
        [EmailAddress(ErrorMessage = "Enter a valid email")]
        public string Email { get; set; }
        [Required]
        public string CompanyName { get; set; }
        [MaxLength(25, ErrorMessage = "The position can be maximum 25 characters long")]
        public string Position { get; set; }
    }
}

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Chris
Posted on: 04 Apr 2024 15:00

Hi Dimo

I understand that you wanted to lock down the component rendering, but it's taken a massive step backwards in terms of functionality.

I had (on my page) 2 FormItem components that I had in a div because I wanted them on the same line rather than 2.  In the old version, this worked perfectly and looked correct.  As soon as I jumped to v4.1.0 I noticed that it had all gone wrong and I had items being rendered all over (all subsequent versions from that point rendered the same broken way).

The upgrade notes listed here (https://docs.telerik.com/blazor-ui/components/form/formitems/formitemstemplate) outlines a very complicated method to achieve the same result as before.  I'm sure the other commenters on this post would agree that the functionality offered in v4.0.1 was the most flexible.

I did go looking for any upgrade notes that would explain the issues I was seeing (https://docs.telerik.com/blazor-ui/upgrade/breaking-changes/4-0-0) and (https://docs.telerik.com/blazor-ui/upgrade/rendering-changes/4-3-0) but neither of them reference this change.

I know it's not in the short-term plan to offer both, but I would request that this is reconsidered because I don't want to upgrade beyond v4.0.1 until it's been rectified as it will involve a lot of refactoring (that shouldn't be required).  Or at the very least, potentially supply a simpler extra component that allows us to mix and match rendering (see below, with FormItemTemplate)?

I know it's similar to what was listed in the upgrade path, but it could potentially be a simpler and easier method to use if we can just add a simple tag that allows us to put whatever we want inside.  Jumping between <FormItems> and <FormItemsTemplate> adds a lot of extra complexity.

<TelerikForm> <FormItems> <FormItemTemplate> <div class="singleRowWrapper"> <FormItem Field="FieldName1" />

<FormItem Field="FieldName2" />

</div> </FormItemTemplate> <FormItem Field="FieldName3"> <Template> ... </Template> </FormItem> </FormItems>

ADMIN
Dimo
Posted on: 04 Apr 2024 14:23

Hi Chris,

Sorry about the disappointment with this new feature.

Currently we are monitoring how many customers need the old behavior and we may consider having both out-of-the-box. However, I must confirm that this is not in our short-term plans.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Chris
Posted on: 04 Apr 2024 14:04

I too have just 'upgraded' from v4.0.1 to v5.1.1 and then found that all of my custom markup had gone missing.

How it worked in v4.0.1 was ideal - any version from that point onwards requires lots of unecessary extra work to put back to how it was.

Considering it's been noticed by quite a few people and nobody likes this change, can it be reverted in the next version (or we are given an option to use either the old or new style)?  Otherwise I will just revert to (and keep at) v4.0.1 until someone comes up with a viable method that doesn't require double the code to achieve the same result.

Arash
Posted on: 03 Nov 2023 23:41

I upgraded a few months ago and ran into the same issue! All custom and dynamically generated forms stop working. I had to downgrade and wait but still the same issue with V4.6.0!

Could you please just bring the old form back with a new name like 'TelerikBasicForm' or 'TelerikSimpleForm' or something like that?

Please leave it to the developers to select and use either one.

 

Brandon
Posted on: 05 Sep 2023 18:51

Every form in our application is now broken as well. I hope another solution is found because I can't justify going from the simple, straightforward markup in 4.0.1 to the 4.2.0 markup shown in the documentation. Not when we have many forms with dozens of controls.

If we have to refactor all of our forms across multiple projects (800+) because of this, we'll probably do it without Telerik.

Mikkel
Posted on: 31 Aug 2023 13:55

Hi Victor

we ended up creating a simple form control based on Telerik's but without the actual form control - not ideal, but workable until this is maybe fixed.

razor:

@using Telerik.Blazor.Components.Form
@*@page "/form/templates"*@
@inject NavigationManager NavigationManager

<div class="demo-section">
    <form class="k-form telerik-blazor k-form-md" style="">
        <FormGridLayout Columns="@Columns" ColumnSpacing="@ColumnSpacing">
            <CascadingValue Value="@EditContext">
                <CascadingValue Value="@Model">
                    <CascadingValue Name="FormContainer" Value="@this" IsFixed="true">
                        @FormItems
                    </CascadingValue>
                </CascadingValue>
            </CascadingValue>
        </FormGridLayout>
    </form>
</div>

code:


    public partial class Form : IFormContainer
    {

        [Parameter]
        public object Model { get; set; }

        [Parameter]
        public RenderFragment FormItems { get; set; }        

        [Parameter]
        public EditContext EditContext { get; set; }
        [Parameter]
        public RenderFragment FormValidation { get; set; }
       
        [Parameter]
        public TelerikForm FormRef { get; set; }

        [Parameter]
        public int Columns { get; set; }

        [Parameter]
        public string ColumnSpacing { get; set; }

        #region Unused
        /// <summary>
        /// These parameters are required from Telerik version 4.1 and up - we do not use them for anything, but they are required to use Teleriks form items
        /// </summary>
        public FormValidationMessageType ValidationMessageType { get; set; } = FormValidationMessageType.None;
        public string Size { get; set; }

        public List<IFormItemBase> FormItemsCollection { get; } = new List<IFormItemBase>();

        public void AddFormItem(IFormItemBase item)
        {
        }

        public IEnumerable<IFormItemBase> GetAutogeneratedItemsFromModel()
        {
            return FormItemsCollection;
        }

        public void RemoveFormItem(IFormItemBase item, bool isAutoGenerated = false)
        {
        }

        #endregion
    }

 

Víctor
Posted on: 31 Aug 2023 11:31

You guys just broke all my forms in my application with this breaking change... not cool at all.

Dale
Posted on: 21 Jun 2023 13:23
I would also agree with Mikkel. Being able to disable Autogenerated columns would be perfectly acceptable to get back that previous functionality.
Mikkel
Posted on: 20 Jun 2023 09:11

Hi Dimo

We don't really need the ability to have any autogenerated form items, so it would not need to work in conjunction with that. Would it be possible for you to maybe have it as an option to disable the autogeneration and set the form control to "manual" mode? That would fix this issue for us. Otherwise we will probably have to move away from using your form and just make our own version.

Best Regards

Mikkel

ADMIN
Dimo
Posted on: 01 Jun 2023 08:15

Hi Mikkel,

I am sorry that the change requires a lot of refactoring on your side. I realize this comes as an unexpected development effort for you.

The current solution is the best that we came up with, in order to support both conflicting features at the same time, even though custom markup inside the Form used to work "automagically" and unofficially. Otherwise we will need two separate Form components, or one public-facing Form with two separate internal algorithms. Both options represent a considerable overhead with questionable business value.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Mikkel
Posted on: 01 Jun 2023 07:12
We have a similar issue when upgrading to the 4.2.0 version from 4.0.1. As we have a a lot of forms (300+) in the enterprise application we are building, the implications of the 4.2.0 change is massive. It will most likely be easier for us to build our own form that supports custom content, than refactoring the forms.
ADMIN
Dimo
Posted on: 02 May 2023 05:13

Hello everyone,

When moving to version 4.2.0 or later, please refer to this new documentation article and especially these two sections:

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
ADMIN
Dimo
Posted on: 22 Mar 2023 12:16

Hello Stewart,

With version 4.1.0 we released a desired feature - combine auto-generated form items together with manually declared ones:

As a side effect, the new feature broke an approach that customers used before - the ability to put arbitrary content inside the <FormItems> RenderFragment. This wasn't originally intended to be officially supported, although I agree that it makes sense to do so, and we have even suggested it to customers in some cases.

We are now researching how to restore the old behavior together with the new feature.

    My recommendation is to keep an eye on our release notes and updated documentation for an official confirmation once the fix is included in the product, which may be as early as the next release in April.

    Please accept our apologies if the current situation is causing you trouble. As a temporary workaround, you can:

    • Stay with version 4.0.1; or
    • Move the whole <AuthorizeView> logic outside the Form. This will require Form markup duplication.

    (I renamed the title to be more general.)

    Regards,
    Dimo
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    James
    Posted on: 17 Mar 2023 16:58
    I have a similar issue where the formitems that are in a TabStrip control display at the bottom and outside the tab content area. Rolled back to previous version to get it back to working.