Developer forum

Forum » Templates » Getting the value from a specific field outside the FieldValues loop in a Form.Submit

Getting the value from a specific field outside the FieldValues loop in a Form.Submit

Jesper Holm Damgaard
Reply

I'm using the Forms for editors module. After submitting a form i want to display the data on a confirmation page in a custom design. In order to do so, i need to control where to display field values according to the design.

I would have thought that it would be possible to do something like this:
<!--@LoopStart(Form.Submits)-->
  <p>Dream senario: |<!--@Form.Submits.Field.Weight.Value-->| </p>
<!--@LoopEnd(Form.Submits)-->

But it seems that this is not the case. To get the value from a specific field i have to do this:
<!--@LoopStart(Form.Submits)-->
  <!--@LoopStart(FieldValues)-->
    <!--@If(Field.SystemName=='Weight')-->
      <p>Reality: |<!--@SubmitData.Value-->|</p>
    <!--@EndIf-->
  <!--@LoopEnd(FieldValues)-->
<!--@LoopEnd(Form.Submits)-->

Obviously this is far from ideal. Does anyone have any experience or suggestions how to optimize this?

 

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Jesper

You should be able to use the tag Form.Field.Weight.Value on submits directly. Not indside a loop, but in the root of the template.

Try adding a @DwTemplateTags to the template root.

Alternatively a Razor can do it.

BR Nicolai

 
Jesper Holm Damgaard
Reply

Ahh, yes. But that requires the s parameter to be present in the url.

I my case i need to show a new page with the latest submit, and a list of all previous submits.

Which means that i cannot rely on the parameter to be present. And i need the data inside the loop as well, to be able to show the complete list of submits.

Makes sense?

 
Nicolai Høeg Pedersen
Reply

Ah, that use case - did not think of that.

I've added Field.{systemName}.Value template tag for each field every time a submit is rendered, TFS#20143 ready in next hotfix.

BR Nicolai

 
Jesper Holm Damgaard
Reply

Sweet, thanks a lot! When is this hotfix due for release?

 
Nicolai Høeg Pedersen
Reply

8.7.2.1 is the one - it does not have a release date yet, but probably sometime this week.

 
Kevin Steffer
Reply

Is it somehow possible to link to an entry (FormSubmitID) 

It doesn't look like we have API access to Encrypt the FormSubmitID?

 
Martin Christensen
Reply

Can I accomplish this in razor without using a confirmation template?

I've tried the following with no luck:

  @foreach (LoopItem sub in GetLoop("Form.Submits"))
  {
    <tr>
      foreach(LoopItem val in sub.GetLoop("FieldValues")) {
        <td>
          <p>@val.GetString("SubmitData.Value")</p>
        </td>
      }
    </tr>
  }

 
Nicolai Høeg Pedersen
Reply

Hi Martin

You in the root of the confirmation template GetString("Field.{0}.Value") where {0} is the system name of your field.

 

You must be logged in to post in the forum