How to Get Current Structure Field Entry in a Query?

Hi all!

I have a structure field, in which each entry will have some HIDDEN fields, which I’d then like to display inside an INFO field. I’d like to be able to use the query language to display the data from the hidden fields as the text of the info field. Example:

received_data:
  type: structure
  label: Received Data
  fields:
    name:
      type:  hidden
    age:
      type: hidden
    data_display:
      type:  info
      label: Entry
      text: "**Name:** {{???.name}} - age:  {{???.age}}"

As you can imagine, I thought that there might be an easy way to access the fields in the same structure field record, but after trying a few different things, I can’t seem to find it: item.name, record.name, data.name, nothing works.

Is there a shortcut that I’m missing, or am I going about it totally the wrong way?

Any suggestions greatly appreciated!

I don’t think this works with the query language because the reference is missing here. But I currently have no idea how to solve that. Why don’t you use disabled fields instead of hidden fields to display the values?

This is a really complicated setup, so please bear with me.

I’m building a ‘form builder’. So, there is a structure field for the user to define which fields they want displayed on the form. The fields will, of course, vary in number and content.

As the form is submitted by site visitors, I’ll have the form submissions STORED into another structure field, on the same page. The tricky part here, is that we don’t know in advance what data we’re storing - we don’t know what the fields are for that form, and in fact, the customer might actually change the configuration of a live form, adding/removing fields after submissions have already been received.

My thinking here is that the best solution is to just keep it plain, and flexible: the submissions are going to be stored with a ‘date (and time)’ field, and then just a ‘content’ field, which will store the complete text of the form data, with field labels and everything. So, in the end, the form controller will store something like this for each entry in the ‘submissions’ structure field:

-
  date: 2019-08-08 09:00 
  content: |
    **Name**: John Smith
    **Email:** john@example.com
    **Message**:
      Hi there! 

As the content is going to be saved (slightly) formatted like in the example above, I’d like to be able to hide the raw text, and just display it inside an Info field (which will format it).

I’m quite happy to hear other suggestions, though! :slight_smile:

You could create a custom field that displays the submissions as a table.

Am I right to assume that the hidden fields are in addition to the content field?

The idea was to have:

  • a ‘date’ field, which is automatically populated with the submission date and time, and is displayed in the structure field table
  • a hidden ‘content’ field, that stores submitted data, along with field labels
  • a ‘key’ field, which stores the label+value of the first field in the form, just to display it in the structure field (makes it easier to pinpoint entries in the table)
  • a ‘display’ field, which was supposed to be an INFO field that would automatically render the contents of the ‘content’ field. This field would only be displayed in the single-record view of the structure field (when the user clicks to view/edit the record)

I don’t really want to go down the path of developing a whole new ‘structure’ field, when we’re SO CLOSE with the Info field already… I feel like there must be something I’m overlooking… Or am I really the first one to come across this limitation with structure field records and the query language?..

For the time being, I’m going to implement this simply using a read-only, monospaced textarea field, instead of the info field. It’s less elegant, but will do the job until something better comes.

I’ve also added a feature request to the ideas repo.