In my project I have a tickets
which are edited in multiple steps where each step has it's own front end for. Now, of course. to continue editing an ticket I am required to fetch that exact ticket.
To accomplish this I have a search form include which will be displayed before the form is showed. When the search form returns an entry the form is shown, when this fails the search form include will be shown again.
Lastly: The search does work when I search for an entry where the title does not contain a spacebar, So:
When the title is 'Test' I can find it, when the title is test ticket
I can't find it using the search form, even though they do both exist!
My code:
General.php settings:
'defaultSearchTermOptions' => [
'attribute' => 'title',
'exact' => true,
'subRight' => false,
'subLeft' => false,
],
My search form:
<form novalidate>
<input id="search" type="search" name="ticket_number"/>
<button type="submit">Search</button>
</form>
My URL
after submitting the form:
domain.com?ticket_number=ticket+number+test+search
My page:
{% set searchQuery = craft.app.request.getParam('ticket_number') %}
{% set ticket = craft.entries().search(searchQuery).section('ticketLog').one() %}
{% if ticket|length %}
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="card-title">Start Picking - {{ ticket.title }}</h4>
<h6 class="card-subtitle">Fill in this form to start picking.</h6>
{% include '/_components/includes/form' with {
'redirect' : siteUrl,
'section_handle' : 'ticketLog',
'fields' : [{
type : 'datetime',
handle : 'pickingStartTime',
},{
type : 'user',
title : 'Picker',
query : 'teamleader',
required : 'required',
size : '12',
}, {
type : 'submit',
text : 'Save Ticket',
}]
} %}
</div>
</div>
</div>
</div>
{% else %}
<p>Your search for “{{ searchQuery }}” didn’t return any Tickets, please try again below.</p>
{% include 'ticket_log/forms/search_form.twig' %}
{% endif %}
Hope someone sees what I am doing wrong there!