Closed michael-ye closed 3 years ago
You can avoid modifying the PropertyVM type by using a creating a DoPostbackAttribute and putting that on your property. The PropertyVm exposes the custom attributes, which you can then use in the razor view.
Does that solve the problem?
On Thu, 27 May 2021 at 16:56, michael-ye @.***> wrote:
We are looking for a "postback" kind of functionality on form field change event.
I can make this work by adding a property to the ProjectVM
//Adding a DoPostback property to the PropertyVM public class PropertyVM : IHasDisplayName { ... ... public string DoPostback {get; set;} }
And modifying the FormFactory rendering razor view classes, for example in Property.System.String.cshtml, modifying the following line of code and adding onchange attribute:
<select name="@Model.Name" onchange="@Model.DoPostBack" class="form-control" @Html.Raw(Model.Readonly()) @Html.Raw(Model.Disabled()) @Html.Raw(isRequired ? "required" : "")>
Then, in the the asp.net core razor view file, handle the DoPostBack with javascript:
@using https://github.com/using FormFactory
@model https://github.com/model List
@Model.Render(Html) <input type="submit" value="submit" /> </form>
If a PropertyVM with DoPostBack property set, at changes, the view will popup and then do a Postback. This works but I am looking for advice on how we can do this without directly changing FormFactory. Is there a way that we can extend FF and accomplish what we need?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mcintyre321/FormFactory/issues/106, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACDJ6X5BJFCWJGSVOTPOSDTPZTTLANCNFSM45UTSO6A .
Thanks, I think this will solve the problem of modifying PropertyVm.
Can you suggest how to avoid modifying Property.System.String.cshtml (adding the onchange attribute) and all other types?
Answer my own question here. In FormFactory project, there is a _ReadMe.txt file under the folder Views/Shared/FormFactory which indicates that we can modify these view files and override the ones that would be loaded from the FormFactory assembly.
I think this would work for us.
Yes, you should be able to add your own views and override the defaults. I haven't actually tried it for a few .net core versions though...
On Thu, 27 May 2021, 17:24 michael-ye, @.***> wrote:
Answer my own question here. In FormFactory project, there is a _ReadMe.txt file under the folder Views/Shared?FormFactory which indicates that we can modify these view files and override the ones that would be loaded from the FormFactory assembly.
I think this would work for us.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mcintyre321/FormFactory/issues/106#issuecomment-849769234, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACDJ6WPBOANIFRQURNVV73TPZW3BANCNFSM45UTSO6A .
This is working on asp.net core 3.1
Thank you for the great work. It has made our work a lot simpler!
We are looking for a "postback" kind of functionality on form field change event.
I can make this work by adding a property to the ProjectVM
//Adding a DoPostback property to the PropertyVM public class PropertyVM : IHasDisplayName { ... ... public string DoPostback {get; set;} }
And modifying the FormFactory rendering razor view classes, for example in Property.System.String.cshtml, modifying the following line of code and adding onchange attribute:
Then, in the the asp.net core razor view file, handle the DoPostBack with javascript:
If a PropertyVM with DoPostBack property set, at changes, the view will popup and then do a Postback. This works but I am looking for advice on how we can do this without directly changing FormFactory. Is there a way that we can extend FF and accomplish what we need?