Skip to content

Commit 153d47d

Browse files
committed
gppa-populate-child-entries.php: Fixed field does not populate on first load issue.
1 parent 1ae5515 commit 153d47d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gp-populate-anything/gppa-populate-child-entries.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public function output_script() {
132132

133133
self.setupPeidField = function() {
134134

135-
var gpnfCookie = $.parseJSON( self.getCookie( 'gpnf_form_session_{0}'.gformFormat( self.formId ) ) );
135+
var gpnfCookie = $.parseJSON( self.getCookie( self.cookieName ));
136136

137-
if ( ! self.$peidField.val() ) {
137+
if ( ! self.$peidField.val() && gpnfCookie ) {
138138
self.$peidField
139139
.val( gpnfCookie.hash )
140140
.change();
@@ -182,6 +182,7 @@ public function add_init_script( $form ) {
182182
'formId' => $form['id'],
183183
'fieldId' => $this->get_parent_entry_id_field( $form ),
184184
'nestedFormFieldIds' => wp_list_pluck( $this->get_nested_form_fields( $form ), 'id' ),
185+
'cookieName' => ( new GPNF_Session( $form['id'] ) )->get_cookie_name(),
185186
);
186187

187188
$script = 'new GPPAPopulateChildEntries( ' . json_encode( $args ) . ' );';

0 commit comments

Comments
 (0)