pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

Frontend form: jQuery not loading? #4822

Open paddelboot opened 6 years ago

paddelboot commented 6 years ago

Issue Overview

Displaying a pods form in frontend. Date field is not showing a datepicker. Console says "ReferenceError: jQuery is not defined".

Expected Behavior

jQuery plugins like datepicker working for frontend forms.

Current Behavior

jQuery Datepicker is not showing when clicking the date field.

Possible Solution

Possibly have an option somewhere within the Pods settings to load/enqueue JS in frontend calls also. This would reduce the amount of JS loaded for people that use Pods only in the backend.

Steps to Reproduce (for bugs)

  1. Create a pod with a date field.
  2. Show pod in frontend via [pods-form] shortcode.
  3. Click on the date field and wait for the datepicker.

Pods Package Export (helpful!)

{"meta":{"version":"2.7.1","build":1522850067},"pods":{"100":{"id":100,"name":"status","label":"Status","description":"","type":"pod","storage":"table","object":"","alias":"","fields":{"pci_status_status":{"id":106,"name":"pci_status_status","label":"Status","description":"","help":"","class":"","type":"pick","weight":0,"pick_object":"custom-simple","pick_val":"","sister_id":"","pick_custom":"A\nB\nC","required":"0","unique":"0","pick_format_type":"single","pick_format_single":"radio","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"projekt_id":{"id":109,"name":"projekt_id","label":"Projekt-ID","description":"","help":"","class":"","type":"text","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"default_value":"{@get.projekt_id}","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"1","roles_allowed":["administrator"],"text_repeatable":"0","text_placeholder":""},"pci_status_datum":{"id":111,"name":"pci_status_datum","label":"Sichtbar bis","description":"","help":"","class":"","type":"datetime","weight":2,"pick_object":"","pick_val":"","sister_id":"","required":"0","unique":"0","datetime_type":"format","datetime_format":"mdy","datetime_time_type":"12","datetime_time_format":"h_mma","datetime_time_format_24":"hh_mm","datetime_allow_empty":"1","datetime_html5":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"datetime_repeatable":0,"datetime_format_custom":"","datetime_format_custom_js":"","datetime_time_format_custom":"","datetime_time_format_custom_js":""}},"show_in_menu":"1","label_singular":"Status","pod_index":"id","hierarchical":"0","ui_style":"post_type","ui_actions_enabled":["add","edit","duplicate","delete"],"ui_reorder_field":"menu_order","ui_fields_manage":{"0":"name","2":"modified"}}}}

WordPress Environment

See below.

Copy and paste your System Details from Pods Admin > Settings > Debug Information in WordPress admin here.

WordPress Version: 4.9.5

PHP Version: 7.2.3-1+ubuntu16.04.1+deb.sury.org+1

MySQL Version: 5.7.21

Server Software: Apache/2.4.18 (Ubuntu)

Your User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0

Session Save Path: /var/lib/php/sessions

Session Save Path Exists: Yes

Session Save Path Writeable: Yes

Session Max Lifetime: 1440

Opcode Cache:

    Apc: No
    Memcached: No
    OPcache: Yes
    Redis: No

Object Cache:

    APC: No
    APCu: No
    Memcache: No
    Memcached: No
    Redis: No

WPDB Prefix: nx24_2_

WP Multisite Mode: Yes

WP Memory Limit: 64M

Pods Network-Wide Activated: No

Pods Install Location: /media/Entwicklung/Entwicklung.****/****/wp-content/plugins/pods/

Pods Tableless Mode Activated: No

Pods Light Mode Activated: No

Currently Active Theme: **** Interface Theme

Currently Active Plugins:

    Duplicator: 1.2.34
    Gravity Forms: 2.2.6
    **** Interface: 0.1
    Pods - Custom Content Types and Fields: 2.7.1
quasel commented 6 years ago

Hi is this still an issue? Sorry for the late reply, feel free to comment if you still have questions!

paddelboot commented 6 years ago

Hi is this still an issue?

My workaround is to load jQuery through my plugin/theme in the frontend. I don't know if this has been resolved.

pglewis commented 6 years ago

A couple things here:

The initial reports lists Pods 2.7.1, has this been tested with the latest?

Have you disabled all other plugins to see if this may be a conflict/interaction?

jQuery should be properly set as a dependency for the fields that need it and if this were a chronic issue I would expect dozens of reports. That suggests it could be some interaction or an edge case that requires a certain combination to reproduce. I'll try the package provided on my end and see if it reproduces.

paddelboot commented 6 years ago

jQuery should be properly set as a dependency for the fields that need it and if this were a chronic issue I would expect dozens of reports.

This is about frontend forms, which is an edge case I guess. Since the issue can be fixed quite easily (and the frontend depends on jQuery anyway), I didn't look into it any further.

pglewis commented 6 years ago

This is about frontend forms, which is an edge case I guess.

I've recently checked several field types on the front-end, both via shortcode and form(), while looking into some CSS issues on #5056 and haven't run across it yet.

paddelboot commented 6 years ago

I think I ran into this issue on a clean WP install, where no other plugins or custom themes were installed and therefore no jQuery was loaded in the frontend. In 90% of installations, this issue will never appear because jQuery is omnipresent in frontend stuff.

pglewis commented 6 years ago

I'll see if I can reproduce it, should be very easy to fix if I see it happen.

paddelboot commented 6 years ago

Ok, thanks.