Skip Navigation

[Résolu] Plus minus input in CRED form

This support ticket is created Il y a 7 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par Nigel Il y a 7 années.

Assisté par: Nigel.

Auteur
Publications
#587971
plus-minus.png

Hi,

is there any option, how to make plus minus input for CRED forms?

#587997

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi Dave

It is not something supported by CRED, though you could add it using a 3rd-party JavaScript library easily enough.

You would add a text input to the form and then initialise the library for that element. The precise steps would depend very much on the library you choose. I expect if you google you'll find many. Here's the first one I found that looks a good candidate, with detailed instructions: lien caché

You'll need to add the JS that initiates the library in the custom JS editor on your CRED form, and you will need to enqueue the library JS and CSS files correctly (https://developer.wordpress.org/themes/basics/including-css-javascript/).

If you try and run into problems let me know (and let me know which library you are using).

#588058

Hi Nigel,

I have found the same plus minus solution 🙂 and succesfully placed it on my CRED form followed the steps shown in document. But how can I connect it with CRED field?

	<div class="form-group">
		<label>Amount</label>
		[cred_field field='amount' post='my-cpt' value='' urlparam='' class='form-control' output='bootstrap']
	</div>

Counter:

<div class="handle-counter" id="handleCounter">
  <button class="counter-minus btn btn-primary">-</button>
  <input type="text" value="1">
  <button class="counter-plus btn btn-primary">+</button>
</div>
#588077

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

The cred_field shortcode will wrap the input in a div so you will need to do some DOM manipulation to match the format shown in the documentation, with button input button before you initialise the counter library.

If I were doing this I would add the HTML for both buttons to my form immediately after the cred_field shortcode, then move those buttons to the required positions in the DOM inside the wrapper div, using something like jQuery's insertAfter()
(lien caché).

And you will probably want to set an initial value for the field in the cred_field shortcode.