Henk Z Henk Z - 4 months ago 25
Smarty Question

Edit php template

I want to edit my php template, but I can not get it right.
I use the the Smarty template engine.

My default php line looks like this:

{$customfield.input|replace:'>' : 'class="form-control" >'}


I have another php tag like, that I want to combine:
{$customfield.name}


I tried this, but that does not work:

{$customfield.input|replace:'>' : 'placeholder="'.{$customfield.name}.'" class="form-control" >'}


How can I fix this?

Answer

Your syntax is wrong. You can't use "." to concatenate strings in smarty. Try this instead:

{$replaceby = 'placeholder="'|cat:$customfield.name|cat:'" class="form-control" >'}
{$customfield.input|replace:'>' : $replaceby}