Jump to content

Custom contact form auto-fill & required fields


bedelz

Recommended Posts

Hi,

 

I'm pretty new with PS but a lot of searching and surfing this forum sure helps a lot!

Still I've bumped onto a problem.

I've put together my own contact-form by combining a couple.

Now I just want a couple of things fixed.

  • Make some fields required (subject, first name, last name, email adress, message)
  • Auto-filled fields when someone's logged in

Does anyone know how to do this in the code?

 

Thanks in advance!

 

Below is the code of my form untill now:

 

<h1>{l s='Klantenservice'} - {if isset($customerThread) && $customerThread}{l s='Your reply'}{else}{l s='Contact us'}{/if}</h1>
{if isset($confirmation)}
<p>{l s='Your message has been successfully sent to our team.'}</p>
<ul class="footer_links">
 <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
</ul>
{elseif isset($alreadySent)}
<p>{l s='Your message has already been sent.'}</p>
<ul class="footer_links">
 <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
</ul>
{else}
<p class="bold">{l s='Voor vragen over producten, bestellingen of  Bedelz.nl kunt u onderstaand contactformulier gebruiken.'}.</p>
<br>
{include file="$tpl_dir./errors.tpl"}
<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std" enctype="multipart/form-data">
 <fieldset>
		    <h3>Bericht versturen</h3>
  <p class="select">
    <label for="id_contact">{l s='Subject Heading'} <font color="#CC0000" size="+1">*</font></label>
  {if isset($customerThread.id_contact)}
    {foreach from=$contacts item=contact}
	 {if $contact.id_contact == $customerThread.id_contact}
	  <input type="text" id="contact_name" name="contact_name" value="{$contact.name|escape:'htmlall':'UTF-8'}" readonly="readonly" />
	  <input type="hidden" name="id_contact" value="{$contact.id_contact}" />
	 {/if}
    {/foreach}
  </p>
  {else}
    <select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">
	 <option value="0">{l s='-- Choose --'}</option>
    {foreach from=$contacts item=contact}
	 <option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>
    {/foreach}
    </select>
  </p>
  {/if}
		    <p class="text">
		    <label for="name">Voornaam <font color="#CC0000" size="+1">*</font></label>
		    <input type="text" id="name" name="name" value="">
		    </p>
		    <p class="text">
		    <label for="lastname">Achternaam <font color="#CC0000" size="+1">*</font></label>
		    <input type="text" id="lastname" name="lastname" value="">
		    </p>
		    <p class="text">
		    <label for="email">Uw e-mailadres <font color="#CC0000" size="+1">*</font></label>
		    <input type="text" id="email" name="from" value="">
		    </p>
		    <p class="text">
		    <label for="street">Straat + huisnr.</label>
		    <input type="text" id="street" name="street" value="">
		    </p>
		    <p class="text">
		    <label for="zipcode">Postcode</label>
		    <input type="text" id="zipcode" name="zipcode" value="" style="width:60px;" maxlength="7">
		    </p>
		    <p class="text">
		    <label for="city">Plaats</label> <input type="text" id="city" name="city" value="">
		    </p>
		    <p class="text">
		    <label for="order">Bestelnummer</label> <input type="text" id="order" name="order" value="">
		    </p>
		    <p class="textarea">
		    <label for="message">Uw bericht <font color="#CC0000" size="+1">*</font></label>
		    <textarea cols="20" id="message" name="message" rows="15" style="width:340px;height:220px"></textarea>
		    </p>
		    <p class="submit"> <input type="submit" name="submitMessage" id="submitMessage" value="Verzend bericht" class="button_large" onclick="$(this).hide();">
		    </p>
		    <font color="#CC0000" size="+1">*</font> Verplichte velden
</fieldset>
</form>
{/if}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...