Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

how can i make this work?

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
torpedo
Smarty n00b


Joined: 05 Aug 2016
Posts: 2

PostPosted: Fri Aug 05, 2016 4:15 pm    Post subject: how can i make this work? Reply with quote

i tried several things but nothing worked..

i just need to add the id of the method into the input field..

<td class="radiobutton">{$method_data.radio_field|replace:'<input type':'<input class="with-gap" id="{$method_data.id}" type'}<label for="{$method_data.id}">{$method_data.title} </label></td>

any help would be appreciated
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Sun Aug 07, 2016 1:56 pm    Post subject: Re: how can i make this work? Reply with quote

If I'm right Smarty inside a modifier will not work.

Try something like this

Code:

{$rbutton = str_replace('<input type', '<input class="with-gap" id="{$method_data.id}" type', $method_data.radio_field}
<td class="radiobutton">{$rbutton}<label for="{$method_data.id}">{$method_data.title} </label></td>
Back to top
View user's profile Send private message
torpedo
Smarty n00b


Joined: 05 Aug 2016
Posts: 2

PostPosted: Sun Aug 07, 2016 5:23 pm    Post subject: Reply with quote

hmm, doesnt work..
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Mon Aug 08, 2016 11:25 am    Post subject: Reply with quote

Do you got an error message?

What says the error log?

Which Smarty version do you are using?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5059
Location: Hamburg / Germany

PostPosted: Tue Oct 25, 2016 3:24 am    Post subject: Reply with quote

The problem is that the second parameter was a single quote string. So the {$method_data.id} was not detected as a smarty tag. make it double quoted and escape the existing '"'.

Code:
<td class="radiobutton">{$method_data.radio_field|replace:'<input type':"<input class=\"with-gap\" id=\"{$method_data.id}\" type"}<label for="{$method_data.id}">{$method_data.title} </label></td>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP