Skip Navigation

[Resolved] Unique Field Identifier

This support ticket is created 6 years, 8 months ago. 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
- 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)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 6 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#646301

Hi guys,

I have been working with CRED for a while now and I am facing a very frustrating issue.
There are no unique field identifiers. Each field does have an ID, but that seems to be randomized.

This makes it really difficult to target for example date fields of similar forms using javascript, in order to perform operations on them. Right now for example, If I want to access a date field (the real Unix timestamp one), I have to add a class to the .form-group field and go down a couple of levels to target the correct form then the correct element within the .form-group wrapper, when I could just target and ID and be done with it.

would it be possible to add a field ID similar to how gravity forms does it (GF_1_1) <- where the first 1 is the form ID and the second is the field ID.

Even a class would do.

Thank you

#646721

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Adrian

I will pass this request on to the developers.

In the meantime, do you know that the cred_field shortcode has a class attribute where you can add custom classes? (https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field)

That may help, though I just double-checked it worked and found that for some field types, e.g. radios and checkboxes, the custom class is not added. If you auto-generate your form and the class attribute is automatically inserted (with a form-control class, for example) then you can add additional classes. If you have to manually add the class attribute, that seems to be when it doesn't work.

So, I'm raising this second point that the class attribute should work for all field types, and I'll request an ID option.

#676308

I did try that, but I am trying to access a date field via jQuery. I know the actual date field is hidden, but for some infuriating reason it has no unique class I can hook into. If I add a custom class to the date field, it just adds it to the fake date field with the calendar, not the actual date field with the unix timestamp. If I apply the class to the enclosing element, the classes for the fake and real input are basically similar. To make things worse, the IDs are randomized on each page load.

Really tough to operate on those fields using Javascript

#677725

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Adrian

If you want to target the hidden date input you can use its name attribute.

See in the screenshot I have a date field "wpcf-start-date", and I can access the hidden date field with jQuery like so:

$("input[name='wpcf-start-date[datepicker]']").val("123");