olliedog Posted January 30, 2014 Share Posted January 30, 2014 Does anyone know how to put text in a customer field? I am setting up WordPress automatically, but I'm using custom fields for the admin,password etc see attached, but would like to have text all ready in the custom field for example in the password field, i would like it to say 'password here.' I've used this tutorial to make it work and its great, but would like to solve this small issue http://www.softaculous.com/docs/WHMCS_Auto_Install_Module#List_of_Scripts Andy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 30, 2014 Share Posted January 30, 2014 Hi Andy, Does anyone know how to put text in a customer field? the most thorough solution might be to replace {$customfield.input} in the template with your own smarty code to generate the form, but in this case it may not be necessary to do this... the quick solution to do what you want is to modify {$customfield.input} to add a value and use onfocus to remove the text when the field is clicked on... if we take the comparison template as an example, and look at configureproduct.tpl - somewhere around line 118, you'll see... <tr> <td class="fieldlabel">{$customfield.name}:</td> <td class="fieldarea">{$customfield.input} {$customfield.description}</td> </tr> this will need to be modified with {if} statements to work out which customfield is being displayed and enter the appropriate text into the form field (btw - if you were using customfield descriptions in the box instead, there would be no need for this!).. <tr> <td class="fieldlabel">{$customfield.name}:</td> <td class="fieldarea">{if $customfield.id eq "18"} {$customfield.input|replace:'value=""':'value="password here..." onFocus="this.value=\'\'"'} {elseif $customfield.id eq "19"} {$customfield.input|replace:'value=""':'value="name here..." onFocus="this.value=\'\'"'} {else} {$customfield.input}{/if} {$customfield.description}</td> </tr> in your case, $customfield.id will not be 18 & 19, but you can find out their correct values by either using {debug} in the template, or probably quicker by viewing the page source in the browser. other order form templates might be slightly different, but the principle should work in any of them... just replace {$customfield.input} with the {if} statements and everything should be ok. 0 Quote Link to comment Share on other sites More sharing options...
olliedog Posted January 31, 2014 Author Share Posted January 31, 2014 Hi Andy, the most thorough solution might be to replace {$customfield.input} in the template with your own smarty code to generate the form, but in this case it may not be necessary to do this... the quick solution to do what you want is to modify {$customfield.input} to add a value and use onfocus to remove the text when the field is clicked on... if we take the comparison template as an example, and look at configureproduct.tpl - somewhere around line 118, you'll see... <tr> <td class="fieldlabel">{$customfield.name}:</td> <td class="fieldarea">{$customfield.input} {$customfield.description}</td> </tr> this will need to be modified with {if} statements to work out which customfield is being displayed and enter the appropriate text into the form field (btw - if you were using customfield descriptions in the box instead, there would be no need for this!).. <tr> <td class="fieldlabel">{$customfield.name}:</td> <td class="fieldarea">{if $customfield.id eq "18"} {$customfield.input|replace:'value=""':'value="password here..." onFocus="this.value=\'\'"'} {elseif $customfield.id eq "19"} {$customfield.input|replace:'value=""':'value="name here..." onFocus="this.value=\'\'"'} {else} {$customfield.input}{/if} {$customfield.description}</td> </tr> in your case, $customfield.id will not be 18 & 19, but you can find out their correct values by either using {debug} in the template, or probably quicker by viewing the page source in the browser. other order form templates might be slightly different, but the principle should work in any of them... just replace {$customfield.input} with the {if} statements and everything should be ok. Perfect, thanks for your reply, will try this is a bit Andy 0 Quote Link to comment Share on other sites More sharing options...
olliedog Posted January 31, 2014 Author Share Posted January 31, 2014 Hi Brian, I don't seem to be able to get this to work. This is my code from the browser <tr><td class="fieldlabel">Script:</td><td><select name="customfield[2]" id="customfield2"><option value="WordPress">WordPress</option></select><br />Select The Script To Install</td></tr> <tr><td class="fieldlabel">Admin Name:</td><td><input type="text" name="customfield[3]" id="customfield3" value="" size="30" /><br />Select your Admin Name for the script.</td></tr> <tr><td class="fieldlabel">Admin Pass:</td><td><input type="text" name="customfield[4]" id="customfield4" value="" size="30" /><br />Select your Admin Pass for the script.</td></tr> <tr><td class="fieldlabel">Directory:</td><td><input type="text" name="customfield[5]" id="customfield5" value="" size="30" /><br />Select the directory you want to install the script at.</td></tr> </table> </div> Do i replace <td class="fieldarea">{if $customfield.id eq "18"} with <td class="fieldarea">{if $customfield.id eq "3"} or <td class="fieldarea">{if $customfield.id eq "customfield3"} Ive tried both and neither seem to work thanks Andy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 31, 2014 Share Posted January 31, 2014 Hi Andy, it would be <td class="fieldarea">{if $customfield.id eq "3"} you'll probably need to empty the template cache - utilities -> system -> system cleanup -> empty template cache and occasionally, you may have to go back to starting the test order again rather than refreshing the product config page... found that myself when testing the code as my changes weren't showing up when refreshing! btw - i've assumed you're using product custom fields rather than client custom fields - hopefully you are! 0 Quote Link to comment Share on other sites More sharing options...
olliedog Posted January 31, 2014 Author Share Posted January 31, 2014 Hi Brian, Iive cleared the cache in my browser and in WHMCS but the text does not show up, this is what I have, am i missing something stupid? <tr> <td class="fieldlabel">{$customfield.name}:</td> <td class="fieldarea">{if $customfield.id eq "3"} {$customfield.input|replace:'value=""':'value="password here..." onFocus="this.value=\'\'"'} {elseif $customfield.id eq "4"} {$customfield.input|replace:'value=""':'value="name here..." onFocus="this.value=\'\'"'} {else} {$customfield.input}{/if} {$customfield.description}</td> </tr> thanks Andy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 31, 2014 Share Posted January 31, 2014 Hi Andy, I just tried your code above on my order form (with a change of id numbers) and it works fine... http://prntscr.com/2ocnk7 can you confirm that you're using the comparison order form? if it's modern, i've just tried the above code in there and it works too. what does view source in the browser show for the customfield code? 0 Quote Link to comment Share on other sites More sharing options...
olliedog Posted January 31, 2014 Author Share Posted January 31, 2014 Hi Brian, the source shows the following, it is setup like this in the orderforms>modern>configureproduct.tpl http://www.softaculous.com/docs/WHMCS_Auto_Install_Module#List_of_Scripts <tr><td class="fieldlabel">Script:</td><td><select name="customfield[2]" id="customfield2"><option value="WordPress">WordPress</option></select><br />Select The Script To Install</td></tr> <tr><td class="fieldlabel">Admin Name:</td><td><input type="text" name="customfield[3]" id="customfield3" value="" size="30" /><br />Select your Admin Name for the script.</td></tr> <tr><td class="fieldlabel">Admin Pass:</td><td><input type="text" name="customfield[4]" id="customfield4" value="" size="30" /><br />Select your Admin Pass for the script.</td></tr> <tr><td class="fieldlabel">Directory:</td><td><input type="text" name="customfield[5]" id="customfield5" value="" size="30" /><br />Select the directory you want to install the script at.</td></tr> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2014 Share Posted February 1, 2014 Hi Andy, thanks for your PM with the link, it was very helpful. the source shows the following, it is setup like this in the orderforms>modern>configureproduct.tpl there's the problem - you've been editing the wrong order form template! your order form template for this product isn't "modern" - it's "web20cart" (which I should probably have recognised from your original screenshot!) - so I bet if you switch to modern, it will work! the code for web20cart should be to replace... <tr><td class="fieldlabel">{$customfield.name}:</td> <td>{$customfield.input}{if $customfield.description}<br />{$customfield.description}{/if}</td></tr> with the following (untested - but looks right to me!) <tr> <td class="fieldlabel">{$customfield.name}:</td> <td>{if $customfield.id eq "3"} {$customfield.input|replace:'value=""':'value="password here..." onFocus="this.value=\'\'"'} {elseif $customfield.id eq "4"} {$customfield.input|replace:'value=""':'value="name here..." onFocus="this.value=\'\'"'} {else} {$customfield.input}{/if}{if $customfield.description}<br />{$customfield.description}{/if}</td> </tr> 0 Quote Link to comment Share on other sites More sharing options...
olliedog Posted February 1, 2014 Author Share Posted February 1, 2014 Hi Brian, Thanks for all your help, but it still does not work, i have the modern template selected in setup>general setting>ordering>modern see screen shot code as you have listed and its still the same I must be doing something stupid/easy any idea? Andy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 1, 2014 Share Posted February 1, 2014 I must be doing something stupid/easy - any idea? yes... product group template settings can overrule the default order form settings... if you goto products/services -> products/services... take a look at the product group, it must be specified to be using web20cart as the order form template for the group... you either have to switch it to default, or modify the web20cart template as above. 0 Quote Link to comment Share on other sites More sharing options...
olliedog Posted February 1, 2014 Author Share Posted February 1, 2014 Brian, thanks for all your help and patience, you were correct products/services -> products/services did the trick, it was set to voice host:!: Andy 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.