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

Add a wapper element for all content fields to allow show/hide field using Javascript #12341

Closed
MikeAlhayek opened this issue Sep 5, 2022 · 0 comments · Fixed by #12347
Closed
Milestone

Comments

@MikeAlhayek
Copy link
Member

MikeAlhayek commented Sep 5, 2022

Is your feature request related to a problem? Please describe.

There is no easy way to hide/show content fields "label and input as a group" using javascript event because there is no wrapper element to select.

Describe the solution you'd like

I think all of the content fields should have a wrapper element to allow the user to easily hide/show the entire field block using javascript.

For example, the TextField will go from looking like this

@{
    var settings = Model.PartFieldDefinition.GetSettings<TextFieldSettings>();
    var culture = await Orchard.GetContentCultureAsync(Model.Field.ContentItem);
}

<div class="mb-3">
    <label asp-for="Text">@Model.PartFieldDefinition.DisplayName()</label>
    <input asp-for="Text" class="form-control content-preview-text" dir="@culture.GetLanguageDirection()" />
    @if (!String.IsNullOrEmpty(settings.Hint))
    {
        <span class="hint">@settings.Hint</span>
    }
</div>

to looking like this

@using OrchardCore.Mvc.Utilities
@{
    var settings = Model.PartFieldDefinition.GetSettings<TextFieldSettings>();
    var culture = await Orchard.GetContentCultureAsync(Model.Field.ContentItem);
    var fieldName = Model.PartFieldDefinition.Name;
}

<div class="mb-3 field-wrapper [email protected]()" id="@Html.IdFor(x => x.Text)_FieldWrapper">
    <label asp-for="Text" class="form-label">@Model.PartFieldDefinition.DisplayName()</label>
    <input asp-for="Text" class="form-control content-preview-text" dir="@culture.GetLanguageDirection()" />
    @if (!String.IsNullOrEmpty(settings.Hint))
    {
        <span class="hint">@settings.Hint</span>
    }
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants