2

Experiencing an odd issue when using @Html.Glass().Editable() inside the value property of an input element. My markup is:

<input type="submit" name="search" value="@Html.Glass().Editable(Model, x => x.CTA_Text)" class="btn btn-large btn-solid color-buttercup form-element find-event-search-button" />

However when the page loads in the Experience Editor, this renders an actual input element inside of the value property of the input, instead of just a string, which is what usually happens when I use Editable():

<input type="submit" name="search" value="<input id='fld_C80D3EEEFE5345C5BCB17FB8ED4D6203_FDE27EC865D34C2A95238FF1091EA131_en_1_3fe281910f0e48b19ab2431af39551f1_5700' class='scFieldValue' name='fld_C80D3EEEFE5345C5BCB17FB8ED4D6203_FDE27EC865D34C2A95238FF1091EA131_en_1_3fe281910f0e48b19ab2431af39551f1_5700' type='hidden' value=" search"="">

1 Answer 1

2

This is exactly the expected behavior, as Editable renders out everything that is necessary for the Experience Editor to render the field as editable. First, you're going to put the normal value into the value attribute, and then you're going to make the field editable elsewhere.

<input type="submit" name="search" value="@Model.CTA_Text" class="btn btn-large btn-solid color-buttercup form-element find-event-search-button" />

Then, make your field editable outside of that, only in the experience editor. Something like:

@if (Sitecore.Context.PageMode.IsExperienceEditorEditing) {
    @:Search CTA Text: @Html.Glass().Editable(Model, x => x.CTA_Text)
}

This will add a second editable area apart from the main search field that will only be visible in the Experience Editor, where your editors can change the value.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.