-
Notifications
You must be signed in to change notification settings - Fork 54
Description
I want to use ui_patterns to provide components with Bootstrap 5 behaviour (eg accordion, modal). When a user clicks, the behaviour should trigger. The modal_name displays fine so I know my modal is working. The preview modal in /patterns also works fine.
My pattern-modal.html.twig is
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#{{modal_name|replace({' ': ''}) }}">
{{ modal_name }}
</button>
<!-- Modal -->
<div class="modal fade" id="{{modal_name|replace({' ': ''}) }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{ modal_name }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{{ modal_description }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I have tried various things in the 'data-bs-target' and 'id' slots. The above example uses the twig replace filter which gives an error of its own = 'Warning: strtr() expects parameter 1 to be string,'. I tried testing with a 3rd field in my content type, where I typed in a js-friendly string. Same result.
Whatever I try the output in the DOM has no data.
data-bs-target="#"
and
id=""
I am using a display suite view mode, consumed by a view which outputs a block on the page. The block renders the component buttons correctly, but of course clicking does nothing.
Could someone please explain the correct way of specifying these trigger and target id items in a pattern?
Many thanks