oTree Forum >

Conditioning formfields for the HTML

#1 by felmola

Hello everyone,

Suppose in round 1, form_fields = ['link_to_p1, 'link_to_p2', 'link_severed_to_p1', 'link_severed_to_p2']
And I want them separated in two columns as

<div class="row">
  <div class="column">
      Link:
      {{ formfield 'link_to_p1' }}
      {{ formfield 'link_to_p2' }}    
  </div>
  <div class="column">
      Permanent:
      {{ formfield 'link_severed_to_p1' }}
      {{ formfield 'link_severed_to_p2' }}

  </div>
</div>

But in a 8/16 players game, the arguments passed into form_fields depend on the one player’s previous answers (and is different for each player, i.e. a heavy conditional). Also, the _px termination in the form fields is non consecutive. But for simplicity assume that in round 2, form_fields = ['link_to_p1, 'link_to_p5', 'link_severed_to_p1', 'link_severed_to_p5'] (notice the _p2 termination is no longer in the formfields).

Is there a way to dynamically fill the rows in the two-column table above? Note that most certainly than not, the number of rows will be different across players (in a round) and across rounds.

If you have any ideas on how this could be acomplished it would be great.
Thank you,
Felipe

Write a reply

Set forum username