Jump to content

[solved] adresses.tpl preentered values? [except auth controller]


BoKr

Recommended Posts

<p style="margin-left:50px;">{l s='You must register at least one phone number'}
<sup style="color:red;">*</sup></p>
<p class="text">
<label for="phone">{l s='Home phone'}</label>
<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}
{$smarty.post.phone}{else}{if isset($address->phone)}
{$address->phone|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>
<p class="text">
<label for="phone_mobile">{l s='Mobile phone'}</label>
<input type="text" id="phone_mobile" name="phone_mobile"
value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{else}
{if isset($address->phone_mobile)}
{$address->phone_mobile|escape:'htmlall':'UTF-8'}{/if}{/if}" />
</p>

 

Hello,

 

I am trying to achieve that the fields for the 'must have' telephone number and 'my adress' and prefilled.

 

Can you help me please here? Would be so great if customers must not fill these fields if they do not want to. So it is optional ....

 

thanks alot

Edited by B.Köring (see edit history)
Link to comment
Share on other sites

<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}

{$smarty.post.phone}{else}{if isset($address->phone)}

{$address->phone|escape:'htmlall':'UTF-8'}{else}08412345{/if}{/if}" />

 

In code above, add the red code. (change default number I used to anything more useful)

 

 

What version do you use? In 1.5(.4.1) it adds "My address" as default value already for the alias. In the code it looks like this:

 

<input type="text" id="alias" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{else if isset($address->alias)}{$address->alias}{elseif !$select_address}{l s='My address'}{/if}" />

 

 

My 2 cents,

pascal

  • Like 1
Link to comment
Share on other sites

Hi Pascal,

 

I thought I had it already tried like you suggested for the phone no but well, no it works! Moreover, the code change for the 'My adress' field does work, too! Since the if if else ifelse else if? is so tricky I would not have found out my self. Thanks alot!

 

This works now for me:

<p style="margin-left:50px;">{l s='You must register at least one phone number'} {*<sup style="color:red;">*</sup>*}</p>
 <p class="text">
  <label for="phone">{l s='Home phone'}</label>
{*  5.-2013 <input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{if isset($address->phone)}{$address->phone|escape:'htmlall':'UTF-8'}{/if}{/if}" /> *}
  <input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{if isset($address->phone)}{$address->phone|escape:'htmlall':'UTF-8'}{else}012345{/if}{/if}" />
 </p>
 <p class="text">
  <label for="phone_mobile">{l s='Mobile phone'}</label>
  <input type="text" id="phone_mobile" name="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{else}{if isset($address->phone_mobile)}{$address->phone_mobile|escape:'htmlall':'UTF-8'}{/if}{/if}" />
 </p>
 <p class="required text" id="address_alias">
  <label for="alias">{l s='Assign an address title for future reference'}</label>
{* ori <input type="text" id="alias" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{else}{if isset($address->alias)}{$address->alias|escape:'htmlall':'UTF-8'}{/if}{if isset($select_address)}{else}{l s='My address'}{/if}{/if}" /> *}  

{* test this 5.2013 PS forum *}
<input type="text" id="alias" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{else if isset($address->alias)}{$address->alias}{elseif !$select_address}{l s='Downing Street 10'}{/if}" /> 
  {*<sup>*</sup> *}
 </p>

Link to comment
Share on other sites

Hi B.Köring,

Glad I could help. If statements can be a pain in the ... :-)

 

Vekia,

normally they are made required in the object class definition. The class defines an array:

 

public static $definition = array(

...

}

With all fields (attributes) of that class/object. Here they define if the attribute is required or not like this:

 

'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),

 

 

Is that what you were looking for??

  • Like 1
Link to comment
Share on other sites

hello Pascal

my answer is: yes & no ;) YOu've got right that i can disable "required" there, but additional thing:

You have go to the localization -> countries, then click on edit button and remove unwanted fields from the box where you define the address format

  • Like 1
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...