wulfric Posted February 25, 2017 Share Posted February 25, 2017 how do i add the description into the placeholder input field? so for example, this code: {$customfield.input} turns into this html: <input type="text" name="customfield[4]" id="customfield4" value="" size="30" class="form-control"> and I wish to add a placeholder attribute using the smarty snippet. the above html would like: <input type="text" name="customfield[4]" id="customfield4" value="" size="30" class="form-control" placeholder="{$customfield.description}"> -- latest WHMCS using stock six theme and standard_cart order form file \templates\orderforms\standard_cart\configureproduct.tpl line 241 - 261 {if $customfields} <div class="sub-heading"> <span>{$LANG.orderadditionalrequiredinfo}</span> </div> <div class="field-container"> {foreach $customfields as $customfield} <div class="form-group"> <label for="customfield{$customfield.id}">{$customfield.name}</label> {$customfield.input} {if $customfield.description} <span class="field-help-text"> {$customfield.description} </span> {/if} </div> {/foreach} </div> {/if} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 25, 2017 Share Posted February 25, 2017 I would think it would be a spin-off from my post in the thread below... https://forum.whmcs.com/showthread.php?117998-Change-additional-domainfield-to-placeholder&p=476354#post476354 ... that thread was about additional domain fields, but they're just custom domain fields by another name. at a guess, and I haven't tested this, but I assume it would be something along the lines of replacing {$customfield.input} with... {if $customfield.input|strpos:'<input type="text"'===0}{$customfield.input|replace:"/>":" placeholder="`$customfield.description`"/>"}{else}{$customfield.input}{/if} 0 Quote Link to comment Share on other sites More sharing options...
wulfric Posted February 26, 2017 Author Share Posted February 26, 2017 What does the '===0 mean? is there a way to close that properly so sublime doesn't report it as fizzy-wuzzy? I noticed in sublime text editor, it detects bad code and changes all the text thereafter.. like normally everything is pretty color coded and when something is broke, it'll highlight **** as gold / yellow. When I cross-checked with the link you posted, you forgot two back slashes. I added them and this is the code that works perfect. {if $customfield.input|strpos:'<input type="text"'===0}{$customfield.input|replace:"/>":" placeholder=\"`$customfield.description`\"/>"} {else} {$customfield.input} {/if} i also took it a step further, and chose to hide the description field below for a specific product id, and this was what i used to do that (just in case anyone else wants to do this): {if $customfield.description} <span class="field-help-text"> {if $productinfo.pid eq "123"} {else} {$customfield.description} {/if} </span> {/if} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 26, 2017 Share Posted February 26, 2017 What does the '===0 mean? http://us3.php.net/manual/en/language.operators.comparison.php $a === $b will be TRUE if $a is equal to $b, and they are of the same type. and for strpos, where we're checking if a substring starts a string, the documentation specifically states... Use the === operator for testing the return value of this function. I suppose technically we don't need to check if it starts with the substring, but only if it exists somewhere in the string... I was probably just being painstakingly accurate. is there a way to close that properly so sublime doesn't report it as fizzy-wuzzy? I noticed in sublime text editor, it detects bad code and changes all the text thereafter.. like normally everything is pretty color coded and when something is broke, it'll highlight **** as gold / yellow. I can't really help you with Sublime as i've never used it, I tend to code in Notepad++ - and sometimes that will not colour the code correctly... especially when your mixing Smarty and PHP functions - it's just one of those things... i've learnt to trust my coding and it's results. I also took it a step further, and chose to hide the description field below for a specific product id, and this was what i used to do that (just in case anyone else wants to do this): which you could trim down slightly... {if $customfield.description} <span class="field-help-text"> {if $productinfo.pid neq "123"}{$customfield.description}{/if} </span> {/if} 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.