Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active December 11, 2017 23:26
Show Gist options
  • Save zackkatz/4690be6bf8f42e82f4d71f86cd8f8f56 to your computer and use it in GitHub Desktop.
Save zackkatz/4690be6bf8f42e82f4d71f86cd8f8f56 to your computer and use it in GitHub Desktop.
Inline Edit by GravityView - Modify the Inline Edit behavior to auto-show inputs
<?php
/**
* Modify the Inline Edit behavior
*/
add_filter( 'gravityview-inline-edit/js-settings', function ( $js_settings ) {
$js_settings['showbuttons'] = false; // Auto-update when changed
$js_settings['onblur'] = 'ignore';
// Show inputs for _all_ fields
$js_settings['showinputs'] = true;
// Show the input for only one field
// @see http://share.gravityview.co/UMiZi0/3EdmaT23 for example
/*
$field_id = 12;
$form_id = 37;
$js_settings['showinputs'] = sprintf( '.editable[data-fieldid="%d"][data-formid="%d"]', $field_id, $form_id );
*/
/*
// Show only specific field types
$field_types = array( 'select', 'checklist', 'text' );
$selectors = array();
foreach ( $field_types as $field_type ) {
$selectors[] = '.editable[data-type="' . $field_type . '"]';
}
$js_settings['showinputs'] = implode( ',', $selectors );
*/
return $js_settings;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment