Skip Navigation

[Resolved] disable date picker

This support ticket is created 7 years, 2 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 41 replies, has 2 voices.

Last updated by Shane 7 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#571071

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacques,

This is indeed strange, Could you try disable the plugins as well and see if you can manually enter the dates now ?

Thanks,
Shane

#571073
Schermafdruk 2017-09-18 16.38.56.png

Shane,

Sed the image. Turned the Toolset plugins out. Except CRED, Types and Views. But still cann't use the data field.

Jacques

#571100

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacques,

I would like to get a copy of the website for further testing because this is strange as you should be able to manually enter the date fields information.

While I create a duplicate would you mind remaking the form ? This is because on a fresh install i'm able to enter the date information manually.

Please let me know.

Thanks,
Shane

#571101

Do you mean remaking the form als it is with another name?

#571151

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacuqes,

Yes just create a new form rather and autogenerate the shortcodes for the form. I want to see if there is something in the form causing this.

Thanks
Shane

#571209

Shane,

I've made a CRED form:

Name = test fort shane
Shortcode = [cred_form form='test-for-shane' form_name='Test for Shane']

Datefield still blocked

Jacques

#571476

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacques,

I've come up with a solution for this one.

It seems that we will need to use some custom code to convert your single line text to a date timestamp. The disadvantage of this is that we will need to convert it back from timestamp to a human readable date when viewing on the frontend.

Would a solution like this be ok for you ?

Please let me know.
Thanks,
Shane

#571600

Shane,

that's seems ok. Let's try this. Will you provide the code?

Jacques

#571813

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacques,

I can write the code for you. I'll do some testing and let you know once i'm finished with it ok 🙂

Sorry if i'm taking a while to get this resolved for you.

Thanks,
Shane

#571841

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacques,

Thanks for the patience.

Add the following to your functions.php file.

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==3179)
    {
        if (isset($_POST['datum-praktijkdag']))
        {
			
            update_post_meta( $post_id, 'wpcf-datum-praktijkdag', strtotime($_POST['datum-praktijkdag']));
        }
if (isset($_POST['beoordeling-op-werkplek']))
        {
			
            update_post_meta( $post_id, 'wpcf-beoordeling-op-werkplek', strtotime($_POST['beoordeling-op-werkplek']));
        }
if (isset($_POST['beoordeling-theorie']))
        {
			
            update_post_meta( $post_id, 'wpcf-beoordeling-theorie', strtotime($_POST['beoordeling-theorie']));
        }
    }
}

The next step is to change 3179 to the ID of your form.

Next you will need to replace each of the date fields respectively with the following.

<div class="form-group">
		<label>Datum praktijkdag</label>
	
      [cred_generic_field field='datum-praktijkdag' type='textfield' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
	</div>

<div class="form-group">
		<label>Beoordeling op werkplek</label>
      [cred_generic_field field='beoordeling-op-werkplek' type='textfield' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
	</div>

<div class="form-group">
		<label>Beoordeling theorie</label>
[cred_generic_field field='beoordeling-theorie' type='textfield' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":""
}
[/cred_generic_field]
    </div>

Please try this and let me know if it helps.
Thanks,
Shane

#571860

Shane,

Can I do this for all the date fields on all the forms in the system without any conflicts.

#571876

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jacques,

Yes you can but you will need to create separate hooks for each form. So duplicate the hook code per form renaming the function for each copy . Example

add_action('cred_save_data', 'form1',10,2);
function form1($post_id, $form_data)

add_action('cred_save_data', 'form2',10,2);
function form2($post_id, $form_data)

Then you need to create generic fields single line fields for each of the date fields and remove the original date field from the form.

Then just use the appropriate names in the functions and it should work.

Thanks,
Shane