Forked from spivurno/gp-unique-id-editable-inputs-gravity-view.php
Created
September 5, 2016 04:24
-
-
Save phillipwilhelm/11eb5912f75c97b84ddcb5f74a931cd7 to your computer and use it in GitHub Desktop.
GP Unique ID // Gravity Perks // Editable Input for Gravity View
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* GP Unique ID // Gravity Perks // Editable Input for Gravity View | |
* http://gravitywiz.com/documentation/gp-unique-id/ | |
* | |
* Updates the input HTML from "hidden" (default) to "text" when viewing entry via Gravity View edit view. | |
*/ | |
if( function_exists( 'gp_unique_id' ) ) { | |
add_filter( 'gpui_input_html_options', function ( $options ) { | |
if( rgget( 'view' ) == 'entry' && rgget( 'edit' ) ) { | |
$options['input_type'] = 'text'; | |
} | |
return $options; | |
} ); | |
add_action( 'init', function () { | |
if( rgget( 'view' ) == 'entry' && rgget( 'edit' ) ) { | |
remove_filter( 'gform_field_css_class', array( gp_unique_id()->field_obj, 'field_class' ), 10, 3 ); | |
} | |
}, 11 ); | |
// enable GP Read Only for all uuid fields | |
add_filter( 'gform_pre_render', function( $form ) { | |
foreach( $form['fields'] as &$field ) { | |
if( GFFormsModel::get_input_type( $field ) == 'uid' ) { | |
$field->gwreadonly_enable = true; | |
} | |
} | |
return $form; | |
} ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment