Support » Plugin: Caldera Forms - More Than Contact Forms » A way to view entries in interface of form generated with PHP

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Josh Pollock

    (@shelob9)

    They should be visible, if they were recorded properly.

    Form entries are created in Caldera_Forms_Save_Final::save_in_db() I would profile that method to ensure they are being saved properly, by comparing to regular form submissions.

    This is the code that I’ve used to create a form:

    add_action( 'caldera_forms_get_form-contact', function( $form )  {
       $form = array (
         'ID' => 'contact',
         'name' => 'Forma kontaktowa',
         'description' => '',
         'db_support' => 1,
         'pinned' => 1,
         'pin_roles' =>
           array (
             'all_roles' => 1,
             'access_role' =>
           array (
             'editor' => 1,
             'author' => 1,
             'contributor' => 1,
             'subscriber' => 1,
           ),
         ),
         'hide_form' => 1,
         'check_honey' => 1,
         'success' => 'Thanks',
         'avatar_field' => '',
         'form_ajax' => 1,
         'has_ajax_callback' => 1,
         'custom_callback' => 'caldera_on_submission_callback',
         'layout_grid' =>
         array (
           'fields' =>
           array (
             'teaser_form_heading' => '1:1',
             'teaser_form_email' => '1:1',
             'teaser_form_name' => '1:1',
             'teaser_form_about' => '1:1',
             'teaser_form_legal_accept' => '1:1',
             'teaser_form_submit' => '1:1',
           ),
           'structure' => '12',
         ),
         'fields' =>
         array (
           'teaser_form_heading' =>
           array (
             'ID' => 'teaser_form_heading',
             'type' => 'html',
             'label' => 'Nagłówek',
             'slug' => 'teaser_form_heading',
             'conditions' =>
             array (
               'type' => '',
             ),
             'caption' => '',
             'config' =>
             array (
               'custom_class' => '',
               'default' => 'Some text here',
             ),
           ),
           'teaser_form_email' =>
           array (
             'ID' => 'teaser_form_email',
             'type' => 'email',
             'label' => 'teaser-form-email',
             'hide_label' => 1,
             'slug' => 'teaser_form_email',
             'conditions' =>
             array (
               'type' => '',
             ),
             'required' => 1,
             'caption' => '',
             'config' =>
             array (
               'custom_class' => 'teaser-form-row',
               'placeholder' => 'e-mail',
               'default' => '',
             ),
           ),
           'teaser_form_name' =>
           array (
             'ID' => 'teaser_form_name',
             'type' => 'text',
             'label' => 'Your name',
             'slug' => 'teaser_form_name',
             'conditions' =>
             array (
               'type' => '',
             ),
             'caption' => '',
             'config' =>
             array (
               'custom_class' => 'teaser-form-row',
               'placeholder' => 'first and last name',
               'default' => '',
               'mask' => '',
             ),
           ),
           'teaser_form_about' =>
           array (
             'ID' => 'teaser_form_about',
             'type' => 'paragraph',
             'label' => 'Your message',
             'slug' => 'teaser_form_about',
             'conditions' =>
             array (
               'type' => '',
             ),
             'caption' => '',
             'config' =>
             array (
               'custom_class' => 'teaser-form-row',
               'placeholder' => 'message',
               'rows' => 4,
               'default' => '',
             ),
           ),
           'teaser_form_legal_accept' =>
           array (
             'ID' => 'teaser_form_legal_accept',
             'type' => 'checkbox',
             'label' => 'teaser_form_legal_accept',
             'hide_label' => 1,
             'slug' => 'teaser_form_legal_accept',
             'conditions' =>
             array (
               'type' => '',
             ),
             'required' => 1,
             'caption' => '',
             'entry_list' => 1,
             'config' =>
             array (
               'custom_class' => 'teaser-form-row teaser-form-legal-accept',
               'inline' => 1,
               'auto_type' => '',
               'taxonomy' => 'category',
               'post_type' => 'post',
               'value_field' => 'name',
               'default' => '',
               'option' =>
               array (
                 'opt1179306' =>
                 array (
                   'value' => 'my consent',
                   'label' => 'my consent',
                 ),
               ),
             ),
           ),
           'teaser_form_submit' =>
           array (
             'ID' => 'teaser_form_submit',
             'type' => 'button',
             'label' => 'Send',
             'slug' => 'teaser_form_submit',
             'conditions' =>
             array (
               'type' => '',
             ),
             'caption' => '',
             'config' =>
             array (
               'custom_class' => 'teaser-form-row teaser-form-button',
               'type' => 'submit',
               'class' => '',
             ),
           ),
         ),
         'page_names' =>
         array (
           0 => 'Page 1',
         ),
         'conditional_groups' =>
         array (
           '_open_condition' => '',
         ),
         'variables' =>
         array (
           'keys' =>
           array (
             0 => 'orderid',
           ),
           'values' =>
           array (
             0 => '{entry_id}',
           ),
           'types' =>
           array (
             0 => 'passback',
           ),
         ),
         'settings' =>
         array (
           'responsive' =>
           array (
             'break_point' => 'sm',
           ),
         ),
         'mailer' =>
         array (
           'enable_mailer' => 1,
           'sender_name' => 'Some Name',
           'sender_email' => 'some@email.com',
           'reply_to' => 'some@email.com',
           'email_type' => 'html',
           'recipients' => '%teaser_form_email%',
           'bcc_to' => 'some@email.com',
           'email_subject' => 'Contact form',
           'email_message' => 'Thank you',
         ),
       );
    
       return $form;
    });

    It does shows up on front end and it does save entries into the database, but the form is not visible in the admin panel (but I guess I should not expect that since form settings are configured in the code) and neither the entries (but as you said they should be visible).

    The code was generated using the var_export() function. Is it missing anything?

    Thank you in advance for your help.

    Best regards,
    Przemek

    Plugin Author Josh Pollock

    (@shelob9)

    Interesting. It should work, might be because of how you call the form.

    Try:

    add_action( 'caldera_forms_get_form', function( $form, $name  )  {
    if( 'contact' == $name ){
    $form = array();//replace with your array
    }
    return $form;
    
    }

    If that doesn’t work, then you’ll need to hook the submission process directly to Caldera_Forms_Save_Final::save_in_db() which I can show you how to do if needed.

    Hi Josh,

    Thank you for your feedback. If I do it this way the form is not displayed on the front end and is also not visible in the backend. Something else might be wrong here I will try to troubleshoot it over the weekend and get back to you with it.

    But if you could also show me how to do it with Caldera_Forms_Save_Final::save_in_db() that would also be great.

    Thank you,
    Przemek

    Plugin Author Josh Pollock

    (@shelob9)

    Przemek –

    What I suspect, and would appreciate that you confirm by looking at your database, is that the admin viewer only works with DB forms, not that it is not saving in the database. I opened an issue to see what David thinks we can do about this:

    https://github.com/Desertsnowman/Caldera-Forms/issues/262

    Take care,
    Josh

    Hi Josh,

    I can confirm that entries from my ‘contact’ form generated via the PHP are saved in the database. It’s only that I cannot see them in wordpress admin panel just the way I can see entries from DB forms. As a workaround I use DB version of the same form.

    I’ve subscribed to github thread.

    Thank you very much.

    regards,
    Przemek

    Plugin Contributor David Cramer

    (@desertsnowman)

    Sorry, my bad. I thought it was a bug its is a documentation issue.

    to show the form in admin for entry viewing you need to add it to the admin filter caldera_forms_get_forms (plural forms)

    add_filter( 'caldera_forms_get_forms', function( $forms ){
      // add form to admin under the ID my-include
      $forms['my-include'] = apply_filters( 'caldera_forms_get_form-my-include', array() );
      return $forms;
    } );
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘A way to view entries in interface of form generated with PHP’ is closed to new replies.