Skip to main content

GravityView_Edit_Entry_Render

Source: includes/extensions/edit-entry/class-edit-entry-render.php:18

Details

  • Kind: class
  • Namespace: (global)

Properties

PropertyTypeDescription
$loaderGravityView_Edit_Entry
$entryarrayGravity Forms entry array
$view\GV\View.The View.
$formarrayGravity Forms form array (GravityView modifies the content through this class lifecycle)
$form_after_validationarrayGravity Forms form array after the form validation process
$fields_with_calculationarrayHold an array of GF field objects that have calculation rules
$form_idintGravity Forms form id
$view_idintID of the current view
$post_idintID of the current post. May also be ID of the current View.
$is_validarrayUpdated entry is valid (GF Validation object)
$show_previous_buttonboolInternal page button states.

Methods

MethodDescription
prevent_render_form()Don't show any forms embedded on a page when GravityView is in Edit Entry mode
prevent_maybe_process_form()Because we're mimicking being a front-end Gravity Forms form while using a Gravity Forms
is_edit_entry()Is the current page an Edit Entry page?
is_edit_entry_submission()Is the current page an Edit Entry page?
init()Load required files and trigger edit flow
prevent_update_unapproved_meta()Done once from self::preset_approval_fields
save_field_value()Make sure the fileuploads are not overwritten if no such request was done.
edit_entry_form()Display the Edit Entry form
render_form_buttons()Display the Update/Cancel/Delete buttons for the Edit Entry form
filter_modify_form_fields()Modify the form fields that are shown when using GFFormDisplay::get_form()
verify_user_can_edit_post()When displaying a field, check if it's a Post Field, and if so, make sure the post exists and current user has edit rights.
modify_edit_field_input()Fill-in the saved values into the form inputs
gform_pre_validation()Add field keys that Gravity Forms expects.
custom_validation()Make validation work for Edit Entry
get_entry()TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!
merge_field_properties()Override GF Form field properties with the ones defined on the View
set_default_values()Conditional logic isn't designed to work with forms that already have content. When switching input values,
manage_conditional_logic()Disable the Gravity Forms conditional logic script and features on the Edit Entry screen
verify_nonce()Is the current nonce valid for editing the entry?
get_action_labels()Returns labels for the action links on Edit Entry
fake_existing_file_uploads()Returns an upload result for existing temporary uploaded files.

Method Reference

prevent_render_form()

public function prevent_render_form()

Don't show any forms embedded on a page when GravityView is in Edit Entry mode

Adds a __return_empty_string filter on the Gravity Forms shortcode on the wp_head action And then removes it on the wp_footer action

Returns

  • void

Since: 1.16.1

Source: includes/extensions/edit-entry/class-edit-entry-render.php:201

prevent_maybe_process_form()

public function prevent_maybe_process_form()

Because we're mimicking being a front-end Gravity Forms form while using a Gravity Forms

backend form, we need to prevent them from saving twice.

Returns

  • void

Source: includes/extensions/edit-entry/class-edit-entry-render.php:217

is_edit_entry()

public function is_edit_entry()

Is the current page an Edit Entry page?

Returns

  • boolean

Source: includes/extensions/edit-entry/class-edit-entry-render.php:237

is_edit_entry_submission()

public function is_edit_entry_submission()

Is the current page an Edit Entry page?

Returns

  • boolean

Since: 1.9

Source: includes/extensions/edit-entry/class-edit-entry-render.php:252

init()

public function init( $gv_data=null, $entry=null, $view=null, $request=null )

Load required files and trigger edit flow

Run when the is_edit_entry returns true.

Parameters

NameTypeDefaultDescription
$gv_data\GravityView_View_DatanullGravityView Data object
$entry\GV\EntrynullThe Entry.
$view\GV\ViewnullThe View.
$request\GV\RequestnullThe Request.

Returns

  • void

Since: develop Added $entry, $view, $request adhocs.

Source: includes/extensions/edit-entry/class-edit-entry-render.php:330

prevent_update_unapproved_meta()

public function prevent_update_unapproved_meta( $value, $form, $entry )

Done once from self::preset_approval_fields

Parameters

NameTypeDefaultDescription
$value
$form
$entry

Returns

  • string — UNAPPROVED unless something else is inside the entry.

Since: 2.5

Source: includes/extensions/edit-entry/class-edit-entry-render.php:693

save_field_value()

public function save_field_value( $value='', $entry=[], $field=null, $form=[], $input_id='' )

Make sure the fileuploads are not overwritten if no such request was done.

TO ONLY BE USED INTERNALLY; DO NOT DEVELOP ON; MAY BE REMOVED AT ANY TIME.

Parameters

NameTypeDefaultDescription
$valuestring''Field value
$entryarray[]GF entry array
$fieldGF_Field_FileUploadnull
$formarray[]GF form array
$input_idstring''ID of the input being saved

Returns

  • string

Since: 1.20.1

Source: includes/extensions/edit-entry/class-edit-entry-render.php:747

edit_entry_form()

public function edit_entry_form()

Display the Edit Entry form

Returns

  • void

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1226

render_form_buttons()

public function render_form_buttons()

Display the Update/Cancel/Delete buttons for the Edit Entry form

Returns

  • string

Since: 1.8

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1573

filter_modify_form_fields()

public function filter_modify_form_fields( $form, $ajax=false, $field_values='' )

Modify the form fields that are shown when using GFFormDisplay::get_form()

By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.

Parameters

NameTypeDefaultDescription
$formarray
$ajaxbooleanfalseWhether in AJAX mode
$field_valuesarray | string''Passed parameters to the form

Returns

  • array — Modified form array

Since: 1.9

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1591

verify_user_can_edit_post()

public function verify_user_can_edit_post( $field_content='', $field=null, $value='', $lead_id=0, $form_id=0 )

When displaying a field, check if it's a Post Field, and if so, make sure the post exists and current user has edit rights.

Parameters

NameTypeDefaultDescription
$field_contentstring''Always empty. Returning not-empty overrides the input.
$fieldGF_Fieldnull
$valuestring | array''If array, it's a field with multiple inputs. If string, single input.
$lead_idint0Lead ID. Always 0 for the gform_field_input filter.
$form_idint0Form ID

Returns

  • string — If error, the error message. If no error, blank string (modify_edit_field_input() runs next)

Since: 1.16.2.2

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1629

modify_edit_field_input()

public function modify_edit_field_input( $field_content='', $field=null, $value='', $lead_id=0, $form_id=0 )

Fill-in the saved values into the form inputs

Parameters

NameTypeDefaultDescription
$field_contentstring''Always empty. Returning not-empty overrides the input.
$fieldGF_Fieldnull
$valuestring | array''If array, it's a field with multiple inputs. If string, single input.
$lead_idint0Lead ID. Always 0 for the gform_field_input filter.
$form_idint0Form ID

Returns

  • mixed

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1673

gform_pre_validation()

public function gform_pre_validation( $form )

Add field keys that Gravity Forms expects.

Parameters

NameTypeDefaultDescription
$formarrayGF Form

Returns

  • array — Modified GF Form

See Also

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1829

custom_validation()

public function custom_validation( $validation_results )

Make validation work for Edit Entry

Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end form pretending to be a back-end form), validate() doesn't know we can't edit post fields. This goes through all the fields and if they're an invalid post field, we set them as valid. If there are still issues, we'll return false.

Parameters

NameTypeDefaultDescription
$validation_results{

Returns

  • array

Source: includes/extensions/edit-entry/class-edit-entry-render.php:1996

get_entry()

public function get_entry()

TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!

Get the current entry and set it if it's not yet set.

Returns

  • array — Gravity Forms entry array

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2141

merge_field_properties()

public static function merge_field_properties( $field, $field_setting )

Override GF Form field properties with the ones defined on the View

Parameters

NameTypeDefaultDescription
$fieldGF_FieldGF Form field object
$field_settingarrayGV field options

Returns

Since: 1.5

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2293

set_default_values()

public function set_default_values( bool $has_conditional_logic, ?array $form=null ): bool

Conditional logic isn't designed to work with forms that already have content. When switching input values,

the dependent fields will be blank.

We update the defaultValue of all the fields, just before the JavaScript is rendered, in order for the defaults key on the Conditional Logic configuration to be populated properly with the stored values.

Parameters

NameTypeDefaultDescription
$has_conditional_logicboolWhether the form has conditional logic
$formarray | nullnullThe forb object.

Returns

  • bool

Since: 2.48.2

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2406

manage_conditional_logic()

public function manage_conditional_logic( $has_conditional_logic, $form )

Disable the Gravity Forms conditional logic script and features on the Edit Entry screen

Parameters

NameTypeDefaultDescription
$has_conditional_logic
$form

Returns

  • mixed

Since: 1.9

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2593

verify_nonce()

public function verify_nonce()

Is the current nonce valid for editing the entry?

Returns

  • boolean

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2756

get_action_labels()

public function get_action_labels()

Returns labels for the action links on Edit Entry

Returns

  • arraycancel, submit, next, previous array keys with associated labels.

Since: 2.10.4

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2789

fake_existing_file_uploads()

public function fake_existing_file_uploads( $field, $form )

Returns an upload result for existing temporary uploaded files.

Parameters

NameTypeDefaultDescription
$fieldarrayThe field object.
$formarrayThe Form object.

Since: 2.40

Source: includes/extensions/edit-entry/class-edit-entry-render.php:2876