Saltar navegación

[Resuelto] Search box in Relationship select field in a CRED Form not working w/ Bootstrap4

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I have a Form that includes a relationship field. The search box feature inside the select field does not seem to work. I cannot add text in the field and it seems inactive.

Solution: Add the following code that helps prevent a conflict between the Select2.js library and Bootstrap 4:

jQuery(document).ready(function(){
  jQuery.fn.modal.Constructor.prototype._enforceFocus = function() {};
});
This support ticket is created hace 4 años, 11 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: 

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por tobiasF-3 hace 4 años, 11 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#1478183

I have a CRED Form with a relation ship select field.

I am showing this form in a Bootstrap4 modal to the user in the frontend:
enlace oculto
(click on the 'edit' button on the right top corner)

The second row of the form shows the 'Add client' relationship select field.
When I click in the search box to look for more clients, the box stays inactive.

When I use the same CRED form on a simple page, the search box works.

What can I do?

Thanks a lot for your help!
Tobi

#1479699

Hi, please add this script to your Form's JS panel:

jQuery(document).ready(function(){
  jQuery.fn.modal.Constructor.prototype._enforceFocus = function() {};
});

Let me know if that doesn't solve the problem and I can take a closer look.

#1479925
Screenshot 2020-01-27 at 01.37.03.jpg

Hey Christian, nice job! Your code works! There is still something weird going on though since the field is very narrow as opposed to when I look at it outside of the bootstrap modal (please check image in the attachment). Do you have another fix for that? 🙂 Thanks a lot for the great help! Tobi

#1481293

You could try adding some custom CSS to set the width of the select2 element:

span.toolset_select2.toolset_select2-container.toolset_select2-container--default {
    width: 100% !important;
}
#1486621

Thx Chris, this works great. Can you tell me, where I can find CSS information for the form elements and the likes for next time, so I don't have to bother you with similar questions again? 🙂

Is there maybe a documentation of all the css handles of toolset elements?

Thx a lot!
Tobias

#1489499

Can you tell me, where I can find CSS information for the form elements and the likes for next time, so I don't have to bother you with similar questions again?
There's not much in the way of a CSS reference or style guide for Toolset's generated markup. I find the browser inspector tool to be more valuable than any documentation though, since it's immediately available and never outdated. If you're using any of the Bootstrap features, then you can find all their documentation available here:
BS 4.4.1: https://getbootstrap.com/
BS 3.4.1: https://getbootstrap.com/docs/3.4/

Anyway, i's not really possible to predict the necessary overrides for every case because themes and plugins each include their own styles, which may or may not conflict with Toolset. The overrides are variable, based on those factors. I typically use the browser inspector tools to isolate the conflicting styles and override selector clashes with CSS specificity: https://dev.to/emmabostian/css-specificity-1kca

#1489501

Ah perfect answer, Chris, thank you for taking the time of explaining me your process and the tipp with the CSS specificity, that's exactly the ressource, that I was looking for to make things more easy for me to understand, thx a lot. My issue is resolved now. Thank you!