Forum

Thread tagged as: Problem, Addons, Forms

Fatal Error When Submitting Perch Forms

Hi

Never seen this one before when submitting a Perch Form...

Fatal error: Uncaught Error: Call to a member function label() on null in /home/kfour/KB64SXSY/htdocs/cms/addons/apps/perch_forms/runtime.php:25 Stack trace: #0 /home/kfour/KB64SXSY/htdocs/cms/core/lib/Perch.class.php(127): perch_forms_form_handler(Object(PerchAPI_SubmittedForm)) #1 /home/kfour/KB64SXSY/htdocs/cms/core/inc/forms.php(9): Perch->dispatch_form('ProseccoQuote:p...', Array, Array) #2 /home/kfour/KB64SXSY/htdocs/cms/core/inc/forms.php(26): perch_find_posted_forms() #3 /home/kfour/KB64SXSY/htdocs/cms/core/runtime/runtime.php(16): include('/home/kfour/KB6...') #4 /home/kfour/KB64SXSY/htdocs/cms/runtime.php(2): include('/home/kfour/KB6...') #5 /home/kfour/KB64SXSY/htdocs/bubbletastic/request_quote.php(2): include('/home/kfour/KB6...') #6 {main} thrown in /home/kfour/KB64SXSY/htdocs/cms/addons/apps/perch_forms/runtime.php on line 25

. Template looks like this (form needs to be client generated)...

<perch:form id="<perch:content id="formID" type="text" label="Form ID" help="Give the form an ID so submissions can be identified" divider-before="Form Fields" notes-before="NB: Submit a test form first & then go into the Form app to configure the form's settings" />" method="post" app="perch_forms">

        <perch:repeater id="formFields" label="Form Fields">
            <div class="form-group">
                <perch:label for="field<perch:content id="perch_item_index" type="hidden" />"><perch:content id="label" type="text" label="Field Label" /></perch:label>
                <perch:input type="<perch:content id="type" type="select" label="Field type" options="Text|text,Email Address|email,Phone number|tel,Textaera|textarea" />" id="field<perch:content id="perch_item_index" type="hidden" />" label="<perch:content id="label" />" class="form-control input-lg" placeholder="<perch:content id="placeholder" type="text" label="Placeholder" />" />
            </div>
        </perch:repeater>

        <div class="button">
            <perch:input type="submit" value="<perch:content id="btnTxt" type="text" label="Button text" />" class="btn btn--green" />
        </div>
    </perch:form>

. Which outputs...

<form id="form1_ProseccoQuote" action="/bubbletastic/request_quote.php" method="post">


            <div class="form-group">
                <label for="form1_field1">Full name</label>
                <input id="form1_field1" name="field1" class="form-control input-lg" placeholder="Full name" type="text" />
            </div>

            <div class="form-group">
                <label for="form1_field2">Home phone number</label>
                <input id="form1_field2" name="field2" class="form-control input-lg" placeholder="Home phone number" type="tel" />
            </div>

            <div class="form-group">
                <label for="form1_field3">Mobile number</label>
                <input id="form1_field3" name="field3" class="form-control input-lg" placeholder="Mobile number" type="tel" />
            </div>

            <div class="form-group">
                <label for="form1_field4">Email</label>
                <input id="form1_field4" name="field4" class="form-control input-lg" placeholder="Email" type="email" />
            </div>


        <div class="button">
            <input class="btn btn--green" value="Request Quote" type="submit" /><input type="hidden" name="cms-form" value="UHJvc2VjY29RdW90ZTpwZXJjaF9mb3JtczovdGVtcGxhdGVzL2NvbnRlbnQvb3JkZXJfcGFnZXMvZm9ybS5odG1sOjE0OTA3MzYxOTM=" />
        </div>
    </form>

. Diagnostics report...

Perch: 2.8.34
Production mode: Production (100)
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_forms (1.8.3), perch_gallery (2.8.6)
DB driver: PDO
DB tables: perch2_blog_authors (3), perch2_blog_comments (0), perch2_blog_index (144), perch2_blog_posts (4), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (2), perch2_category_counts (0), perch2_category_sets (3), perch2_content_index (3334), perch2_content_items (448), perch2_content_regions (69), perch2_forms (1), perch2_forms_responses (2), perch2_gallery_albums (12), perch2_gallery_image_versions (1185), perch2_gallery_images (237), perch2_navigation (2), perch2_navigation_pages (23), perch2_page_templates (3), perch2_pages (18), perch2_resource_log (1270), perch2_resource_tags (3), perch2_resources (260), perch2_resources_to_tags (3), perch2_settings (28), perch2_user_passwords (1), perch2_user_privileges (41), perch2_user_role_privileges (24), perch2_user_roles (2), perch2_users (5)
Users: 5
PHPMailer: 5.2.21
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_forms',
        'perch_gallery',
        'perch_blog',
    );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: redactor, markitup
H1: 0afa788efffffd920cf5ec353296ae02
L1: 6d934f7accb8cf06537fe36574cc9b21
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
headerColour: #70d549
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.32: done
latest_version: 2.8.15
on_sale_version:
headerScheme: dark
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
logoPath: /cms/resources/perch-logo.png
perch_gallery_update: 2.8.5
update_2.8.34: done
perch_blog_update: 5.0.1
perch_blog_post_url: /blog/{postSlug}
perch_blog_site_name:
perch_blog_slug_format: {postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 30
perch_gallery_bucket_mode: dynamic
perch_gallery_bucket: default
perch_blog_comment_notify: 0
perch_gallery_basicUpload: 0
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: kfour_perch
PERCH_DB_SERVER: kfour.dns-systems.net
PERCH_DB_DATABASE: kfour_perch
PERCH_DB_PREFIX: perch2_
PERCH_TZ: UTC
PERCH_EMAIL_FROM: glen.piggott@soundwave.co.uk
PERCH_EMAIL_FROM_NAME: Glen Piggott
PERCH_LOGINPATH: /cms
PERCH_PATH: /home/kfour/KB64SXSY/htdocs/cms
PERCH_CORE: /home/kfour/KB64SXSY/htdocs/cms/core
PERCH_RESFILEPATH: /home/kfour/KB64SXSY/htdocs/cms/resources
PERCH_RESPATH: /cms/resources
PERCH_HTML5: 1
PERCH_YOUTUBE_API_KEY: AIzaSyAILojFHMCLGJ3ZOr9Rn14qLH7pk4S--kY
PERCH_DEBUG:
PERCH_RUNWAY:
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /home/kfour/KB64SXSY/htdocs/cms/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
HOSTING SETTINGS

PHP: 7.0.15
Zend: 3.0.0
OS: Linux
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
MySQL server: 5.6.33
Free disk space: 565.46 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, gettext, gmp, SPL, iconv, session, intl, json, mbstring, mcrypt, standard, mysqlnd, mysqli, PDO, pdo_mysql, pdo_sqlite, Phar, pspell, Reflection, imap, SimpleXML, soap, exif, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, cgi-fcgi, imagick, mailparse, OAuth, PDFlib, ssh2, memcached, memcache, ionCube Loader
GD: Yes
ImageMagick: Yes
PHP max upload size: 128M
PHP max form post size: 128M
PHP memory limit: 256M
Total max uploadable file size: 128M
Resource folder writeable: Yes
Session timeout: 60 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
REDIRECT_UNIQUE_ID: WNrVyFPfagsAADHoSNsAAAAK
REDIRECT_HTTPS: on
REDIRECT_SSL_TLS_SNI: k4kitchenmakeovers.co.uk
REDIRECT_HANDLER: application/x-httpd-php70
REDIRECT_STATUS: 200
UNIQUE_ID: WNrVyFPfagsAADHoSNsAAAAK
HTTPS: on
SSL_TLS_SNI: k4kitchenmakeovers.co.uk
HTTP_HOST: k4kitchenmakeovers.co.uk
HTTP_CONNECTION: keep-alive
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_REFERER: https://k4kitchenmakeovers.co.uk/cms/core/settings/diagnostics/
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch, br
HTTP_ACCEPT_LANGUAGE: en-GB,en;q=0.8
HTTP_COOKIE: cmsa=1; _ga=GA1.3.269216253.1486043466; PHPSESSID=fppqgpj994upi6334cg6uikd15
PATH: /usr/bin:/bin
SERVER_SIGNATURE: <address>Apache Server at k4kitchenmakeovers.co.uk Port 443</address>
SERVER_SOFTWARE: Apache
SERVER_NAME: k4kitchenmakeovers.co.uk
SERVER_ADDR: 83.223.106.11
SERVER_PORT: 443
REMOTE_ADDR: 87.127.197.165
DOCUMENT_ROOT: /home/kfour/KB64SXSY/htdocs/
SERVER_ADMIN: postmaster@k4kitchenmakeovers.co.uk
SCRIPT_FILENAME: /home/kfour/KB64SXSY/htdocs/cms/core/settings/diagnostics/index.php
REMOTE_PORT: 59624
REDIRECT_QUERY_STRING: extended
REDIRECT_URL: /cms/core/settings/diagnostics/index.php
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /cms/core/settings/diagnostics/?extended
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /usr/local/php70/bin/cgi/php-cgi
ORIG_PATH_INFO: /cms/core/settings/diagnostics/index.php
ORIG_PATH_TRANSLATED: /home/kfour/KB64SXSY/htdocs/cms/core/settings/diagnostics/index.php
ORIG_SCRIPT_NAME: /php70-cgi/php-cgi
PHP_SELF: /cms/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1490736584.5287
REQUEST_TIME: 1490736584
argc: 1
Glen Piggott

Glen Piggott 0 points

  • 4 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

It might be this:

label="<perch:content id="label" />"

in your perch:input with a label Field Type

You've already got a label - try it without this and see if it fixes it.

Thanks Duncan - sadly no luck.

label="<perch:content id="label" />" is in there to give it it's Perch label on the form submission data. By putting in <perch:content id="label" /> it repeats the content from the label field earlier in the template.

Duncan Revell

Duncan Revell 78 points
Registered Developer

Ah well - thought it might be the processing order mucking things up - even though content should be processed before form anyway.

Had a quick look at the code - it appears it's failing to pick up the attributes from the perch:form tag. Maybe try it with a hard-coded form id and see if that works.

Hi Duncan

Hard coding the form ID has made the form submit ok but the data isn't being passed, so I'm guessing you can't put perch:content within perch:form?

I need the client to be able to set the form fields within Perch Admin so I'm not sure the best way to do this?

That's the only downside to Perch Forms - you can't seem to be able to create / edit forms within Perch Admin.

Glen

Duncan Revell

Duncan Revell 78 points
Registered Developer

It looks like it works (a bit) using perch:content within perch:form - but it's falling over when searching the perch:form "string" for attributes. It probably fails because it hits the closing > of perch:content and thinks it's the closing > of perch:form.

So, maybe try putting your attributes (method, app etc) before the id=

I'm not sure how much further you'll get (or if this is recommended), but that will stop the fatal error. Give it a go.

Hi Ducan

Yeap - placing the form ID at after the attributes works. Again however no data is submitted, it just recognises that the form has been submitted.

Glen

Duncan Revell

Duncan Revell 78 points
Registered Developer

I think you've asked the same question before... ;-)

https://forum.grabaperch.com/forum/06-21-2016-form-values-not-being-passed

Well spotted :-)

Bugger!