Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectEditMeta ReadOnly prefix in MudTextField #15

Closed
DennisvanZetten opened this issue Feb 15, 2023 · 1 comment
Closed

ObjectEditMeta ReadOnly prefix in MudTextField #15

DennisvanZetten opened this issue Feb 15, 2023 · 1 comment

Comments

@DennisvanZetten
Copy link

Hi,

Would it be possible to give a string property a readonly prefix?
I try to achieve the following:

I have two properties:

` meta.Property(m => m.Category)
.WithOrder(1)
.WithLabel(_localizer[LK.TranslationsFormCategory])
.RenderWith<CategorySelect, TranslationCategoryDTO>(c => c.Value)
.WrapInMudItem(i => i.xs = 12); ;

meta.Property(m => m.Key)
.WithOrder(2)
.WithLabel(_localizer[LK.TranslationsFormKey])
.WithAdditionalAttributes<MudTextField>(true, t => t.Variant = Variant.Filled);`

I would like to use the category selected as prefix for the key making them a unique combination. The user can only create the key.
So for example

Selected Category is registration.

The key text shows: registration_XXXXXX where the user can only change the XXXXX
Would this somehow be possible?

Thanks in advance

Dennis

@fgilde
Copy link
Owner

fgilde commented Feb 20, 2023

Just for label or description you can use the resolver for label or description and use your Model however you want.
For editing or whatever you can check if the Mask Property helps.

    public TestModel Test { get; set; } = new();


    public class TestModel
    {
        public Gender? Gender { get; set; }
        public string Text { get; set; }
    }

    public enum Gender
    {
        Male,
        Female,
        Other
    }

    private void Configure(ObjectEditMeta<TestModel> meta)
    {

        meta.Property(m => m.Text)
            .WithLabelResolver(i => Test.Gender?.ToString() + "_ Text")
            .WithDescriptionResolver(i => Test.Gender?.ToString())
            .WithAttributesIf<TestModel, MudTextField<string>>(m => m.Gender == Gender.Male, f => f.Mask = new PatternMask("###-##-##"))
            .WithAttributesIf<TestModel, MudTextField<string>>(m => m.Gender == Gender.Female, f => f.Mask = new PatternMask("###-##-##"));
    }

@fgilde fgilde closed this as completed Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants