Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. alex de rafols
  2. F2C submission form templating
  3. Monday, 24 July 2017
  4.  Subscribe via email
We're trying to create a simple conditional statement that will show one question or the other on the submission form, based on the selected answer.

What code is needed to make this work?

Below is the code for the submission form template.
We used the same conditional “IF / Else” from the article template that works perfectly.

However, the code below does not work at all on the submission form page.

We were HOPING that it would be something similar to: If “yes” is chosen for field “ENCOUNTER_PREPARED”, show “TEXTBOX” field. Else, show “TEXTAREA” field.

Thanks for your help!



<div class="f2c_button_bar">
{$F2C_BUTTON_APPLY}{$F2C_BUTTON_SAVE}{$F2C_BUTTON_SAVE_AND_NEW}{$F2C_BUTTON_SAVE_AS_COPY}{$F2C_BUTTON_CANCEL}
</div>
<div class="clearfix"></div><div class="row-fluid form-horizontal">
<div class="control-group f2c_field f2c_title">
<div class="control-label f2c_field_label">{$F2C_TITLE_CAPTION}</div>
<div class="controls f2c_field_value">{$F2C_TITLE}</div>
</div>
<div class="control-group f2c_field f2c_ENCOUNTER_DATE">
<div class="control-label f2c_field_label">{$ENCOUNTER_DATE_CAPTION}</div>
<div class="controls f2c_field_value">{$ENCOUNTER_DATE}</div>
</div> <div class="control-group f2c_field f2c_ENCOUNTER_PREPARED">
<div class="control-label f2c_field_label">{$ENCOUNTER_PREPARED_CAPTION}</div>
<div class="controls f2c_field_value">{$ENCOUNTER_PREPARED}</div></div>
{if $ENCOUNTER_PREPARED eq 'yes'}
<div class="control-group f2c_field f2c_TEXTBOX">
<div class="control-label f2c_field_label">{$TEXTBOX_CAPTION}</div>
<div class="controls f2c_field_value">{$TEXTBOX}</div>
</div>
{else}
<div class="control-group f2c_field f2c_TEXTAREA">
<div class="control-label f2c_field_label">{$TEXTAREA_CAPTION}</div>
<div class="controls f2c_field_value">{$TEXTAREA}</div>
</div>
{/if}
<div class="control-group f2c_field f2c_EDITOR">
<div class="control-label f2c_field_label">{$EDITOR_CAPTION}</div>
<div class="controls f2c_field_value">{$EDITOR}</div>
</div></div><div class="clearfix"></div>
<div class="f2c_button_bar">
{$F2C_BUTTON_APPLY}{$F2C_BUTTON_SAVE}{$F2C_BUTTON_SAVE_AND_NEW}{$F2C_BUTTON_SAVE_AS_COPY}{$F2C_BUTTON_CANCEL}
</div>
<div class="clearfix"></div>
Responses (1)
Julien Accepted Answer Pending Moderation
Hi Alex,

Using the Smarty if statements in the form submission template won't work here, since the templates are pre-rendered on the server-side.
What you need is a dynamic if statement on the client-side. This can be achieved with a combination of javascript and css (which you can include in the form submission template).

Common practice is this:

Wrap the fields you don't want to show directly in a div block and make that hidden through css.
Now trigger a piece of javascript when the user selects an answer.
Let the trigger decide whether to show or hide the div block.

Here is a generic solution that shows similar behaviour: http://jsfiddle.net/QAaHP/16/
Please note that this is not a F2C example, but a generic solution that shows the idea. To integrate this with F2C you have to look at the html and input types that your F2C form uses.

best,
Julien
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.