Forum Moderators: coopster

Message Too Old, No Replies

How to set execution of form when variable is set in Smarty?

         

toplisek

3:06 pm on May 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




I have used Smarty based framework.


I have defined variable inside controller file
$var['contact_form'] = true;
$var['contact_form_code'] = " ";

Form:
form id="contact_form" action="URL" method="post">
<p>

<input type="submit" name="contact_form1" value="Send" class="sendclass" />

How to
1. execute store posted values inside variables and
2. form can be submitted after validation is done?

toplisek

6:32 pm on May 16, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is possible to help?

bkeep

2:11 am on May 17, 2011 (gmt 0)

10+ Year Member



If you mean you have assigned a smarty variable in the php file so
$smarty->assign("contactForm",true);

then in your tpl file something like
{if $contactForm}
form content
{else}
no form content
{/if}
as far as submitting the form after the validation is done would be backwards you can use some javascript to validate some field values on the fly but you still will need to check your input in the php script with some real checking after the form is submitted.

toplisek

7:26 am on May 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This assign is to set form display.

I like to know how to set values from inputs into message (mail script).

I have the following:
<p>
<label class="input1">Familiy name</label>
<input id="text1" name="{$varname}" size="60" maxlength="60" class="required" />
</p>

and assigned:
$smarty->assign('varname', $_POST['varname']);