publicform question

0

Hi, I have a pod with brochures (which contain title, image, description, and an email address). The email-address is used to request a printed version. So I figured I put a Request Brochure link on the detail-POD-page of the brochure and point it to a regular WP-page which has this in the template code (WP Page Template):

like : http://www.highlifeplus.com/aanvraag-brochure?brochure=15 where 15 is the brochure-ID-code.

Now, the form has to do two things, 1. get saved in the brochure-request-POD (so we have the data of the requester if they tick the mailing-option) and 2. get sent to the email-address of the brochure-provider (as provided in the brochures-POD).

Here's what I have so far.

<?php
                        $brochureID = strip_tags($_GET["brochure"]);

                        if (!empty($brochureID)) {
                            $Broc = new Pod('brochures',$brochureID);
                            $Broc->findRecords('ID desc', 1);
                            while($Broc->fetchRecord() ) {
                                $Brocname   = $Broc->get_field('name');
                                $Brocslug   = $Broc->get_field('slug');
                                $Brocemail  = $Broc->get_field('email');
                            }

                            echo '<span style="color: red; font-style:italic;">To be removed after testing : <br />';
                            echo "Brochure ID = " . $brochureID . " | " . $Brocname . "<br />";
                            echo "slug= " . $Brocslug . " - email = " . $Brocemail;
                            echo "</span>";

                            $BRequest = new Pod('brochurerequest');
                            $fields = array(

                                            'slug' => array('hidden' => true),
                                            'salutation',
                                            'firstname',
                                            'name',
                                            'address',
                                            'address2',
                                            'zipcode',
                                            'city',
                                            'country',
                                            'email',
                                            'extrainfo',
                                            'linktobrochure' => array('hidden' => true, 'default' => $brochureID)

                                            );
                            echo $BRequest->publicForm($fields, "Vraag brochure aan");

                        } else {
                            echo "No Brochure requested. You cannot order.";
                        }
                    ?>

But, a few questions: 1. how to set the 'linktobrochure' to the ID of the brochure requested (since I know which brochure they want (passed via link) 'linktobrochure' => array('hidden' => true, 'default' => $brochureID) does not work.. just gives a select-dropdown..

  1. make the slug hidden (apparently : 'slug' => array('hidden' => true) does not work)

  2. remove the editor from the paragraph input field

  3. for the sending of the email, use a pre-save or post-save helper ? and howto retrieve all fields (they are all accessible "in" the form .. also the email-address from the other pod (brochures) ?I have written a sendmail-helper before, but that one sends mail to the blog admin when pods get updated, not to..

asked Oct 5 '10 at 2:22

tomhermans

36

edited Oct 5 '10 at 2:24

add comment
enter at least 15 characters

3 Answers

0

and point 4 got truncated ..

  1. for the sending of the email, use a pre-save or post-save helper ? and howto retrieve all fields (they are all accessible "in" the form .. also the email-address from the other pod (brochures) ?I have written a sendmail-helper before, but that one sends mail to the blog admin when pods get updated, not to..

answered Oct 5 '10 at 2:24

tomhermans

36

add comment
enter at least 15 characters
0

-> remove the editor from the paragraph input field

you can A) use code field instead of pragraph field or B) set css property display to none for the editor. I guess it would be like that

div[selectable="on"] {
    display: none;
}

it would be even better to wrap publicForm:

<div class="formwrapper">
<?php $BRequest->publicForm($fields, "Vraag brochure aan"); ?>
</div>

and make css rule for .formwrapper div[selectable="on"]

answered Oct 5 '10 at 5:28

Fike

208

edited Oct 5 '10 at 5:29

Thanx Fike, I changed it to a code field.. was the simplest option.. and since it is an optional field, doesn't matter that much.. Anybody has an answer for the other questions ? especially about the after-save-helper and the "hidden" fields.. ? – tomhermans Oct 6 '10 at 10:00
add comment
enter at least 15 characters
0

Ok,

tried another approach.

No page template, just displayed the publicform on a pod-detail-page and used a pre-save helper to send mails to different people.

One to the tourist office to request the brochure, one to me as admin (for now), one to the whomever made the request.

Now the 'linktobrochure'=>array('hidden'=>true,'default'=>$brochureID), 'slug'=>array('hidden'=>true)

are still not working..

Am I reading the docs wrong ?:

Each column can optionally be an array of settings. They will override the default settings for the column. Available settings: default hidden label comment input_helper <?php $fields = array( 'name', 'body', 'start_date' => array('input_helper' => 'fancy_date_picker'), 'slug' => array('hidden' => true) ); ?>

answered Oct 6 '10 at 3:34

tomhermans

36

upgrade to 1.9.3.1 did the trick (I guess...) 'linktobrochure'=>array('default'=>$id), 'slug'=>array('hidden'=>true), works like documented – tomhermans Oct 7 '10 at 2:30
add comment
enter at least 15 characters