GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
form-buttons.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file form-buttons.php
4  * @global GravityView_Edit_Entry_Render $object
5  */
6 
7 if ( current_filter() === 'gform_previous_button' ) {
8  if ( $object->show_previous_button || $object->show_update_button ) {
9  return; // Will be called later once more
10  }
11 }
12 
13 if ( current_filter() === 'gform_next_button' ) {
14  if ( $object->show_update_button ) {
15  return; // Will be called later once more
16  }
17 }
18 
19 ?>
20 <div id="publishing-action">
21  <?php
22 
23  /**
24  * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL
25  * @since 1.11.1
26  * @since 2.11 The cancel link now uses history.back() so the $back_link URL matters less.
27  * @param string $back_link Existing URL of the Cancel link
28  * @param array $form The Gravity Forms form
29  * @param array $entry The Gravity Forms entry
30  * @param int $view_id The current View ID
31  */
32  $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id );
33 
34  /**
35  * @action `gravityview/edit-entry/publishing-action/before` Triggered before the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container.
36  * @since 1.5.1
37  * @param array $form The Gravity Forms form
38  * @param array $entry The Gravity Forms entry
39  * @param int $view_id The current View ID
40  */
41  do_action( 'gravityview/edit-entry/publishing-action/before', $object->form, $object->entry, $object->view_id );
42 
43  $labels = $object->get_action_labels();
44 
45  if ( $object->show_previous_button ) {
46  $previous_tabindex = GFCommon::get_tabindex();
47  $previous_label = GFCommon::replace_variables( $labels['previous'], $object->form, $object->entry );
48  ?>
49  <input id="gform_previous_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-previous" type="submit" <?php echo $previous_tabindex; ?> value="<?php echo esc_attr( $previous_label ); ?>" name="save" />
50  <?php
51  }
52 
53  if ( $object->show_next_button ) {
54  $next_tabindex = GFCommon::get_tabindex();
55  $next_label = GFCommon::replace_variables( $labels['next'], $object->form, $object->entry );
56  ?>
57  <input id="gform_next_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-next" type="submit" <?php echo $next_tabindex; ?> value="<?php echo esc_attr( $next_label ); ?>" name="save" />
58  <?php
59  }
60 
61  if ( $object->show_update_button ) {
62  $update_tabindex = GFCommon::get_tabindex();
63  $update_label = GFCommon::replace_variables( $labels['submit'], $object->form, $object->entry );
64  ?>
65  <input id="gform_submit_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" <?php echo $update_tabindex; ?> value="<?php echo esc_attr( $update_label ); ?>" name="save" />
66  <?php
67  }
68 
69  $cancel_tabindex = GFCommon::get_tabindex();
70  $cancel_label = GFCommon::replace_variables( $labels['cancel'], $object->form, $object->entry );
71 
72  // If the entry has been edited, history.back() will keep pointing to the Edit Entry screen. Go back before editing, please!
73  // On first visit, will be history.go(-1) because (0 + 1 * -1).
74  // After updating twice, history.go(-3) because (2 + 1 * -1)
75  $update_count = (int) \GV\Utils::_POST( 'update_count', 0 );
76 
77  /**
78  * @filter `gravityview/edit_entry/cancel_onclick` Modify the `onclick` attribute for the back link. To remove `onclick` altogether, return an empty string.
79  * @since 2.13.4
80  * @param string $back_link Existing "back" of the Cancel link.
81  * @param array $form The Gravity Forms form.
82  * @param array $entry The Gravity Forms entry.
83  * @param int $view_id The current View ID.
84  * @param int $update_count The number of pages to go back based on the # of updates to the edited form.
85  */
86  $cancel_onclick_js = apply_filters( 'gravityview/edit_entry/cancel_onclick', 'history.go(' . ( $update_count + 1 ) * -1 . '); return false;', $object->form, $object->entry, $object->view_id, $update_count );
87 
88  $cancel_onclick = empty( $cancel_onclick_js ) ? '' : 'onclick="' . esc_attr( $cancel_onclick_js ) . '"';
89  ?>
90  <a class="btn btn-sm button button-small gv-button-cancel" <?php echo $cancel_onclick; ?> <?php echo $cancel_tabindex; ?> href="<?php echo esc_url( $back_link ); ?>"><?php echo esc_attr( $cancel_label ); ?></a>
91  <?php
92 
93  /**
94  * @action `gravityview/edit-entry/publishing-action/after` Triggered after the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container.
95  *
96  * @used-by GravityView_Delete_Entry::add_delete_button()
97  *
98  * @since 1.5.1
99  * @since 2.0.13 Added $post_id
100  * @param array $form The Gravity Forms form
101  * @param array $entry The Gravity Forms entry
102  * @param int $view_id The current View ID
103  * @param int $post_id The current Post ID
104  */
105  do_action( 'gravityview/edit-entry/publishing-action/after', $object->form, $object->entry, $object->view_id, $object->post_id );
106  ?>
107  <input type='hidden' name='update_count' value='<?php echo $update_count + 1; ?>'/>
108  <input type="hidden" name="action" value="update" />
109  <input type="hidden" name="lid" value="<?php echo esc_attr( $object->entry['id'] ); ?>" />
110 </div>
$labels
if(current_filter()==='gform_previous_button') if(current_filter()==='gform_next_button') $back_link
if( $object->show_previous_button) if( $object->show_next_button) if( $object->show_update_button) $cancel_tabindex
$cancel_onclick
$cancel_label
$cancel_onclick_js
$update_count