Forum

Thread tagged as: Error, Forms

Perch Form error...blocks related?

I have a form template which submits to the Forms app, which I've done many times. This is the first time I've used a blocks form template, though. There are also several forms on the one page which is unusual for me. Anyway, when a form is submitted, I get this error:

Fatal error: Call to a member function label() on a non-object in D:\{path removed}\addons\apps\perch_forms\runtime.php on line 25

Here's the form template:

<div class="formWrap">

    <h3 class="headS"><perch:content id="title" type="text" label="Title" required="true" title="true" /></h3>
    <perch:content type="image" id="thumb" label="Thumbnail Image" width="500" height="500" quality="80" no-index="true" required="true" suppress="true" />
    <hr>

    <perch:form id="<perch:content id="slug" type="slug" for="title" />" class="inqForm verlag" action="javascript:void(0);" method="post" app="perch_forms">

        <perch:blocks divider-before="Form Fields" >

            <perch:block type="text-input" label="Text Line">
                <div class="infieldWrap">
                    <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" label="Label" required="true" /><perch:content id="required" type="checkbox" label="Required" value="true" suppress="true" /></perch:label>
                    <perch:input type="text" <perch:if exists="required">required="true" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" label="Label" required="true" />" />
                </div>
            </perch:block>

            <perch:block type="email" label="Email">
                <div class="infieldWrap">
                    <perch:label for="email"><perch:content id="label" type="text" label="Label" required="true" /><perch:content id="required" type="checkbox" label="Required" value="true" suppress="true" /></perch:label>
                    <perch:input type="email" <perch:if exists="required">required="true" </perch:if>id="email" label="<perch:content id="label" type="text" label="Label" required="true" />" />
                </div>
            </perch:block>

            <perch:block type="yes-no" label="Yes/No">
                <div class="radioOuter">
                    <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" label="Label" required="true" /><perch:content id="required" type="checkbox" label="Required" value="true" suppress="true" /></perch:label>
                    <perch:input type="radio" options="Yes,No" <perch:if exists="required">required="true" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" label="Label" required="true" />" wrap="div.radioWrap" />
                </div>
            </perch:block>

            <perch:block type="message" label="Message">
              <div>
                <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" label="Label" required="true" /><perch:content id="required" type="checkbox" label="Required" value="true" suppress="true" /></perch:label>
                <perch:input type="textarea" <perch:if exists="required">required="true" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" label="Label" required="true" />" rows="<perch:content id="rows" type="text" label="Rows" size="xs" help="Height of message box in rows, e.g. '5'" required="true" />" encode="false" />
              </div>
            </perch:block>

        </perch:blocks>

        <div class="submitWrap">
            <perch:input type="submit" class="rectLink verlag" id="submit" value="Submit" />
        </div>

        <div class="clearfix"></div>

        <perch:success>
            <script>
                    return 'SUCCESS';
            </script>
        </perch:success>
        <perch:error for="all" type="general">
            <script>
                    return 'Perch Error';
            </script>
        </perch:error>
    </perch:form>

</div>

Page where template/forms are called:

<?php include('{removed}/runtime.php');?> 
<div class="inqPopWrap">
    <div class="royalSlider rsDefault">
        <div>
        <h3 class="headS">Inquire</h3>
        <hr>
        <?php
            perch_content_custom('Forms', array(
                'template'=>'/inquire/landing.html'
            ));
            perch_content('Contact Info');
        ?>
        </div>
    </div>
    <div class="inqHiddenForms">
        <?php perch_content('Forms'); ?>
    </div>
</div>

And here is diagnostics:

Perch: 2.8.11, PHP: 5.5.11, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $, with PDO
Server OS: WINNT, apache2handler
Installed apps: content (2.8.11), assets (2.8.11), categories (2.8.11), perch_blog (4.6), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', );
PERCH_LOGINPATH: {removed}
PERCH_PATH: {removed}
PERCH_CORE: {removed}
PERCH_RESFILEPATH: {removed}\resources
Image manipulation: GD
PHP limits: Max upload 1000M, Max POST 1000M, Memory: 500M, Total max file upload: 500M
Resource folder writeable: Yes
HTTP_HOST: {removed}
DOCUMENT_ROOT: {removed}
REQUEST_URI: {removed}/core/settings/diagnostics/
SCRIPT_NAME: {removed}/core/settings/diagnostics/index.php

Thanks for the help!

EDIT: I should also mention that the error/success messages are in <script> tags because this form is supposed to be AJAX submitted...but I still get the same error message when I submit directly from the page without AJAX.

Shane Lenzen

Shane Lenzen 18 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't use blocks in a form template - that won't work.

Gotcha. It would be awesome to give editors the ability to easily add different types of form fields with the ease of blocks. Any idea if that will be possible in the future?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's not currently planned, but never say never.

Looks like repeaters don't work, either? I get the same error with this:

EDIT: If repeaters don't work, does this mean there is currently no way for an editor to build a form while using the Forms app?

<div class="formWrap">

    <h3 class="headS"><perch:content id="title" type="text" label="Title" required="true" title="true" /></h3>
    <perch:content type="image" id="thumb" label="Thumbnail Image" width="500" height="500" quality="80" no-index="true" required="true" suppress="true" />
    <hr>

    <perch:form id="<perch:content id="slug" type="slug" for="title" />" class="inqForm verlag" action="javascript:void(0);" method="post" app="perch_forms">

        <perch:repeater id="form-fields" label="Form Fields">
            <perch:content id="field-type" type="select" label="Type" options="Text Line|text-line, Email|email, Yes-No|yes-no, Message|message" allowempty="false" required="true" suppress="true" />
            <perch:content id="label" type="text" label="Label" required="true" suppress="true" /><perch:content id="slug" type="slug" for="label" suppress="true" />
            <perch:content id="required" type="checkbox" label="Required" value="true" suppress="true" />

            <perch:if id="field-type" value="text-line">
              <div class="inputWrap infieldWrap">
                <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" /></perch:label>
                <perch:input type="text" <perch:if exists="required">class="required" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" />" />
              </div>
            </perch:if>

            <perch:if id="field-type" value="email">
              <div class="inputWrap infieldWrap">
                <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" /></perch:label>
                <perch:input type="email" <perch:if exists="required">class="required" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" />" />
              </div>
            </perch:if>

            <perch:if id="field-type" value="yes-no">
              <div class="inputWrap radioOuter">
                <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" /></perch:label>
                <perch:input type="radio" options="Yes,No" <perch:if exists="required">class="required" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" />" wrap="div.radioWrap" />
              </div>
            </perch:if>

            <perch:if id="field-type" value="message">
              <div class="inputWrap">
                <perch:label for="<perch:content id="slug" type="slug" for="label" />"><perch:content id="label" type="text" /></perch:label>
                <perch:input type="textarea" <perch:if exists="required">class="required" </perch:if>id="<perch:content id="slug" type="slug" for="label" />" label="<perch:content id="label" type="text" />" rows="6" encode="false" />
              </div>
            </perch:if>
        </perch:repeater>

        <div class="submitWrap">
            <p class="errorContainer"></p>
            <perch:input type="submit" class="rectLink verlag" id="submit" value="Submit" />
        </div>

        <div class="clearfix"></div>

        <perch:success>
            <script>
                return 'SUCCESS';
            </script>
        </perch:success>
        <perch:error for="all" type="general">
            <script>
                return 'CMS Submission Failure';
            </script>
        </perch:error>
    </perch:form>

</div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Blocks and repeaters are basically the same thing, technically. Forms can't be dynamic.

Gotcha. I would like to hereby submit a request for this feature, then. :)