Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marcio Goularte 374 posts 1346 karma points
    Feb 03, 2022 @ 19:23
    Marcio Goularte
    0

    Different create and edit forms

    Is it possible to have a creation form and an editing form? For example, to create the record only a few mandatory fields. After creation, other fields will be available

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Feb 03, 2022 @ 19:48
    Matt Brailsford
    1

    Hi Marcio

    Not currently no. There is just one form used for creation / editing.

    Can you explain the use case?

    Matt

  • Marcio Goularte 374 posts 1346 karma points
    Mar 22, 2022 @ 19:14
    Marcio Goularte
    0

    I have a scenario where the creation has business rules that cannot be edited later. In the creation form there would be a field with an entity type, which according to the choice some fields of the form could be editable or not

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 23, 2022 @ 08:50
    Matt Brailsford
    0

    The best I could suggest is maybe create some custom property editor or maybe a wrapper property editor that is a Create Only Property that detects if the view is a create view and if it is, renders the actual wrapped control and if not, renders the value in whatever format you need?

  • anh-duc-le 36 posts 150 karma points
    Jul 18, 2022 @ 08:35
    anh-duc-le
    0

    Would it be possible to have CreateOnly built into the plugin? We are currently also facing the issue where we want some fields to be editable on create but not after its been created.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 19, 2022 @ 09:50
    Matt Brailsford
    0

    Ok, if anyone wants to test this I think I have something in place.

    I've basically made it so you can pass a predicate to the MakeReadOnly methods on fields and in that we pass a context object which contains the editor mode and user permissions collection so you decide dynamically when a field is readonly.

    The MakeReadOnly method now also supports passing a dattype name / id so you can set a different prop editor to use instead of the label (which is still the default).

    I've also added a SetVisibility method which has the same predicate, but rather than making the field readonly, it completely remove it from the editor.

    Here's an example where an Age field is editable during create, but becomes readonly during edit and when readonly it is formated as "x yearsold". There is also an example of a field that is set to only display during editing and not during create.

    .AddFieldset("General", fieldsetConfig => fieldsetConfig
        .AddField(p => p.JobTitle).MakeRequired()
        .AddField(p => p.Age).MakeReadOnly(x => x.EditorMode == KonstruktEditorMode.Edit, v => $"{v} years old")
        .AddField(p => p.Encrypted).SetVisibility(x => x.EditorMode == KonstruktEditorMode.Edit)
    )
    

    If you want to try this, it's on my unstable nuget feed at https://nuget.outfield.digital/unstable/v3/index.json and you'll want to install the 1.5.0-ALPHA-FIELD-VISIBILITY.38 build (don't install any other version as you may have unexpected results).

    I'd appreciate the feedback as to whether this solves your problems or not.

Please Sign in or register to post replies

Write your reply to:

Draft