Jump to content

Custom Field Query


olliedog

Recommended Posts

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

customFields.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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_ScriptsScreen Shot 2014-01-31 at 22.29.56.png

 

<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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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 Screen Shot 2014-02-01 at 07.50.34.png

 

code as you have listed and its still the same

 

I must be doing something stupid/easy

 

any idea?

 

Andy

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated