BoKr Posted May 17, 2013 Share Posted May 17, 2013 (edited) <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 May 18, 2013 by B.Köring (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted May 17, 2013 Share Posted May 17, 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'}{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 1 Link to comment Share on other sites More sharing options...
vekia Posted May 17, 2013 Share Posted May 17, 2013 My 2 cents, pascal hey pascal, maybe you know how to set fields as not required? I'm checking auth controller but I can't find $this->fields_list definition there :/ Link to comment Share on other sites More sharing options...
BoKr Posted May 18, 2013 Author Share Posted May 18, 2013 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 More sharing options...
PascalVG Posted May 20, 2013 Share Posted May 20, 2013 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?? 1 Link to comment Share on other sites More sharing options...
vekia Posted May 22, 2013 Share Posted May 22, 2013 hello @PascalVG you've got right, but where to edit this? this is main problem for me - i can't find this Link to comment Share on other sites More sharing options...
PascalVG Posted May 24, 2013 Share Posted May 24, 2013 (edited) Vekia, look in the /classes folder and select for example Address.php then search for required or Category.php and search the same Hope this helps, pascal Edited May 24, 2013 by PascalVG capitalization of file names (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 27, 2013 Share Posted May 27, 2013 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 1 Link to comment Share on other sites More sharing options...
PascalVG Posted May 28, 2013 Share Posted May 28, 2013 Hi Vekia, You're right about the address fields. Misunderstood that it was about addresses specifically :-) Glad it's solved :-) pascal Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now