• Resolved johnaq

    (@johnaq)


    I’m very new to Pods and have searched this forum and pods.io for help. I’m just using Pods in WP, no php.

    I have set up 2 pods ‘Events’ and ‘Registrations’. They are related – events can have may child registrations. A registration has only one parent event.

    Using a basic template and shortcode, I can create and view an event page, and put a registration form on that page so someone could register from the front end. However, from what I can tell, the registration form still requires the user to select the related event.

    How can the new registration automatically relate to the event being viewed?

    Have tried to understand relationships and default values, but just can’t quite put it together.

    Thanks in advance

    https://www.ads-software.com/plugins/pods/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    If you have the registration form on the same page with the individual event, you can create a ‘hidden’ field in the form that is set to the related event so that the user doesn’t have to or get to select it.

    How are you creating the Registration Form? Using the form() function from PODS or a shortcode?

    Thread Starter johnaq

    (@johnaq)

    Thanks for the reply Jim.

    I’m using a shortcode to create the form. It’s a very bare bones set up at the moment.

    I guess my question is how do “create a ‘hidden’ field in the form that is set to the related event”? Is that by setting a default value? What would the magic code be for that?

    Thread Starter johnaq

    (@johnaq)

    I’m slowly pulling together an understanding of what magic tags work (and – just as importantly – where) really wish I could find a definitive list/reference.

    So it seems like if I could set the default value of my the ‘event’ field in the relationships pod to {@ID} then I’d be good to go but this doesn’t seem to work from within the shortcode Registration form on an Event page.

    BTW, I really have no idea what Set Default Value by Parameter does

    I hope that all makes sense

    Plugin Contributor Josh Pollock

    (@shelob9)

    There is no way to do a hidden form in a shortcode. Instead use Pods::form()

    https://pods.io/docs/code/pods/form/

    Thread Starter johnaq

    (@johnaq)

    Is there now way to achieve this using ‘Set Default Value’. It seems like a lot of trial and error to figure out what works.

    Where can one learn about ‘via Paramater’

    Plugin Contributor Jim True

    (@jimtrue)

    If you’re not terribly comfortable with PHP, you can do exactly what you’re looking for with the Gravity Forms Plugin for Pods:

    https://github.com/pods-framework/pods-gravity-forms

    Sorry to keep pointing you to different options, but looking at your questions, you don’t seem that comfortable with PHP and the shortcode for forms is VERY rudimentary, there are a large handful of things you can send to that shortcode, though. This article breaks down what’s available:

    https://pods.io/docs/learn/shortcodes/pods/

    it allows you to specify a Pods Template to use, so reasonably, you COULD create a very specific HTML form using a Pods Template and magic tags to include just the fields you want and set the individual event value on the form.

    We don’t really have a way to set a default value for the form, because the form doesn’t know the context of where it is, especially if you’re creating one that is based off another Event. Gravity Forms definitely makes this a little easier.

    Thread Starter johnaq

    (@johnaq)

    Hi Jim

    No need to apologise, thanks for time and help!

    You’re right, I’m no PHP expert, so was keen to explore all options through Pods itself.

    My first impression was that I could achieve what I was after (automatically creating a related registration from an event page) by being able to set the default value of the related registration field and hiding it from the UI using Pods Admin. I’m still not sure why this doesn’t work, and what ‘set via parameter’ does.

    Anyway, I have managed to achieve what I wanted in a Pods template using Pods::form() as follows…

    $regPod = pods( 'registration' );
    $thisEventID = $obj->id();
    $formFields=array('email', 'event' => array( 'default' => $thisEventID, 'type' => 'hidden' ));
    echo $regPod->form($formFields);

    I hope that all makes sense

    Plugin Contributor Jim True

    (@jimtrue)

    Actually that makes perfect sense and is probably the best way to get the form to work the way you’d like without going the Gravity Forms direction.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Automatically create related items’ is closed to new replies.