• Resolved stevefox86

    (@stevefox86)


    For a strange reason the field of nested form are cached.
    Currently the plugin does not export latest fields added

    I’ve found the lines involving this problem inside nestedFormField.php

    // Cache the results.
    		$this->fields = array_reduce( $nested_form['fields'], function ( array $fields, \GF_Field $field ) {
    			if ( in_array( $field->id, $this->field->gpnfFields ?? [], false ) ) {
    				$fields[ $field->id ] = $this->transformer->transform( $field );
    			}
    
    			return $fields;
    		}, [] );

    Disabling the if it is working

    if ( in_array( $field->id, $this->field->gpnfFields ?? [], false ) ) {

    Have you got a solution to refresh the field of nested form from dashboard ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Doeke Norg

    (@doekenorg)

    HI @stevefox86,

    Could you provide me with a little bit more information?

    Do you mean when you have a nested field, and create more fields on THAT form, the export of the parent form does not show these fields?

    And could you provide me with a copy of your system report? (Forms > System Status > Copy System Report). You can send that to doeke[at]gravitykit.com.

    And if you could provide me with an export of the parent and child form that would greatly help as well.

    Thanks in advance.

    – Doeke

    Plugin Author Doeke Norg

    (@doekenorg)

    @stevefox86 Also, just so we are on the same page. Simply adding a field to the nested form is not enough. You need to update the nested field as well, with the “Display Fields” option on that field.

    Those are the only fields that are exported from the nested form. That is exactly what the if is for. So if you remove that; and it works, this probably means you did not update that field on the parent form.

    Please let me know if this helps.

    Kind regards,

    Doeke

    Thread Starter stevefox86

    (@stevefox86)

    the export of the nested form with export lite work correctly and export all the fields.

    The parent is exporting only the string fields and not the others added in second moment.

    “Display Fields” option you are talking about is inside gravity export section of the sub form ?

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @stevefox86,

    On the parent form there is a nested form field, where you connected the child form. When selecting this field, there is a Display Fields option where you select all the fields of the child form you want to show. This needs to be updated to include the fields you want to export.

    Hope that clears things up.

    Thread Starter stevefox86

    (@stevefox86)

    OK you are talking about the summary section where you select the sub fields to be shown in summary table in frontend. In that section i don’t want all fields to be shown but only some of them to avoid scroll-x for the table.

    In my case i need more fields in excel than in the summary in the frontend.

    No problem. Thank you for your prompt support

    Plugin Author Doeke Norg

    (@doekenorg)

    @stevefox86 Right! I added your use case to a feature on our backlog, so it will be easier to add more fields to the output. This will intitally probably be a hook where you programmatically add the field ids. Would that work for you?

    Thread Starter stevefox86

    (@stevefox86)

    Yes a hook could be perfect

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @stevefox86, Maybe you already noticed; but we’ve added a hook to facilitate your request. The hook is called gk/gravityexport/field/nested-form/export-field.

    It receives an array of the field id’s of the nested form to export. So by default it will give the field id’s you have selected on the form, but using this hook you can append or remove from this array.

    Since a nested form is nested on a specific field, you can target that field by adding it to the hook name.

    Here is a full example:

    If you have a parent form (id: 3) with a field (field id: 2) that contains a nested form (id: 5), you would target that specific field with the hook: gk/gravityexport/field/nested-form/export-field_3_2.

    Let’s say you want to add (a hidden) field id 6 of the nested form to the export, it would be something like this:

    add_filter( 'gk/gravityexport/field/nested-form/export-field_3_2', function ( array $fields ): array {
    	$fields[] = '6';
    
    	return $fields;
    }, 10 );

    Hope this helps you out. If you have any questions, please let me know.

    Kind regards,
    Doeke

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Flush nested form field cache’ is closed to new replies.