WebDrawer - Hide And/Or button in search form

When you create a search form you may choose to only give it one field, in which case the And/Or button is redundant (see below).

The cleanest way to hide this button is to edit the razor template that produces the form.  One simple change is required, first open Views\Search.cshtml (in 8.2 Views\FormSearch.cshtml) and then:

Find the HTML that looks like this:

<label class="radio inline">
    <input type="radio" name="BooleanOperator" value="and" />And
 </label>
<label class="radio inline">
    <input type="radio" name="BooleanOperator" value="or" checked />Or
</label>

And wrap it in an IF statement like this:

@if (searchForm.DefinitionForm.Pages.SelectMany(x => x.PageItems).Count() > 1)
{
    <label class="radio inline">
        <input type="radio" name="BooleanOperator" value="and" />And
    </label>
    <label class="radio inline">
        <input type="radio" name="BooleanOperator" value="or" checked />Or
    </label>
}
Written on January 24, 2017