将字符串预先添加到Smarty变量

I'm looking for a way to prepend a string to a Smarty variable. I have a dynamic form having element-names like input-1 (where 1 is the id of the setting/field).

I've tried to do this with {capture}{/capture} but this only seems to work the first time (as the fields are displayed by a loop).

Is there an opposite function from |cat:'text' for Smarty, or do I have to:

  1. Create my own modifier
  2. Rename inputs

I'm not sure I understand what you're trying to achieve, but there is an alternative syntax to cat, using backticks (and much more elegant and clear imho):

Using cat:

{"my string"|cat:$my_var|cat:"other string"|cat:$other_var}

The same, using bacticks:

{"my string `$my_var` other string `$other_var`"}

Using backticks, you can easily place your variables anywhere inside the string:

{"input-`$id`"}

Do you really need it in a variable? I usually do these things like this:

<input name="input-{$id}" type="..." />

If you need it in a variable you can use {assign}:

{assign var="name" value="input-$id"}
<input name="{$name}" type="..." />