Skip Navigation

[Resolved] trying to migrate site to toolset

This support ticket is created 5 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
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)

This topic contains 7 replies, has 2 voices.

Last updated by Christian Cox 5 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1363311
cal scs.png

Tell us what you are trying to do?
trying to migrate php site to toolset using shortcodes and views

Is there any documentation that you are following?
https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/?utm_source=typesplugin&utm_medium=plugin&utm_campaign=product&utm_content=codesnippets

Is there a similar example that we can see?
hidden link

What is the link to your site?
hidden link
hidden link

#1363491

Hello, I'm not quite sure I understand the request. Is there a specific problem you need help solving, or are you looking for assistance recreating an entire application in Toolset? I'll be glad to help with any specific problem, but the forum isn't really designed to help you recreate an entire application. The first problem I see is that Toolset does not offer a calendar View. It's something we have discussed in our blog recently, and asked for feedback: https://toolset.com/2019/06/do-you-need-calendar-view-for-toolset/

Until that calendar view is implemented, this type of design is going to be very custom, and require a lot of custom code.

#1363779

Hello,
having read the blog discussion, a reply given was using toolset it easy to make a basic booking system which is
feature i needed.
so i created a CRED form for adding custom post - availability where user enters a date and set it as available with checkbox. I am able to build calendar view on the cred form with shortcode, so the only missing part is making calendar data aware where page refreshes the calendar view when cred form submitted to show book dates . can i do this using ajax, i added javascript function in the js editor on the post form , but it was not output on the page. can i call js function on post form?
however using get_posts('availability') , i can fill the calendar with cpt marked as available when page loads initially. can i convert get_posts( 'cpt') into mysql syntax, is that possible . thanks

#1363801

There is no AJAX API for Forms, so I don't have an event that you can tap into to listen for a Form submission. I think the only way to update a calendar would be to refresh the page after a Form is submitted. I'm not a SQL expert but you should be able to do something like SELECT * FROM wp_posts WHERE post_type='slug' AND post_status='publish'

#1365111
wr.png

trying to do, after submit of Post form a custom date field go to 'cred_form_validate' and validate the date field 'wpcf-start-date', but the date value is current day not the day user picked . i.e. ' October 20,2019 ' in place of selected date ' October 27,2019 '. hidden link
get error message

#1365703

Can you share the code used in your cred_form_validate hook?

#1371323

add_filter('cred_form_validate','my_validation',10,2);
function my_validation($error_fields, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$error_fields;
//uncomment this if you want to print the field values
// print_r($fields);
//validate if specific form
if ($form_data['id']==387)
{
//check my_field value
$sta = date_i18n( get_option('date_format',$fields['wpcf-start-date']['value']));
$availabilitys = get_posts('post_type=availability');
foreach ($availabilitys as $availability) {
$starttime = get_post_meta($availability->ID, 'wpcf-start-date', true);

// $start = date_i18n( get_option('date_format',$starttime )

if ($fields['wpcf-start-date']['value']!=$starttime)
{
//set error message for my_field 1572393600
$errors['wpcf-start-date']= 'wrong value'.$sta;
}
}

}
//return result
return array($fields,$errors);
}

#1371465

Okay I assume the start-date field is a custom field created in Types. If so, then the data structure for this field is a bit different as you can see in this print_r log of a date field:

[wpcf-book-date] => Array
        (
            [value] => Array
                (
                    [display-only] => 26/09/2019
                    [datepicker] => 1569528869
                    [hour] => 20
                    [minute] => 14
                )

            [name] => wpcf-book-date
            [type] => date
            [repetitive] => 0
            [plugin_type] => types
            [validation] => Array
                (
                    [required] => Array
                        (
                            [active] => 1
                            [value] => true
                            [message] => This field is required.
                        )

                    [date] => Array
                        (
                            [active] => 1
                            [format] => mdy
                            [pattern] => check.format
                            [message] => Please enter a valid date.
                        )

                )

        )

So if you want to get the Unix timestamp of this field, you should use this syntax:

$fields['wpcf-start-date']['value']['datepicker']