Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

how to assign/overwrite the value of an input in template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Wed Jun 27, 2018 6:18 pm    Post subject: how to assign/overwrite the value of an input in template Reply with quote

I have a template, with an input, added via QuickForms $tpl->addElement. Later on, I would like to (from php) be able to overwrite the value of the input - is this possible?

I know I can assign a variable, but not sure how I can access the tpl structure to write a new value.

Added input:
Code:
$form->addElement('text', 'fdatefrom', gettext("Date From"). ':', '  id=fdatefrom size=10 maxlength=10 value="' . $fdatefrom. '"'. $selectclass);


Then later, I would like to be able to change that value in the template object
(which seems to be in $tpl --> _tpl_vars --> form_data -- fdatefrom["value"])
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jun 28, 2018 3:51 pm    Post subject: Reply with quote

I don't see, where you are using TEMPLATE variable.
You're just concatenating a simple string.
Which defeating the very reason to use a template.

P.S.
https://www.smarty.net/docs/en/api.get.template.vars.tpl pretty please.
Back to top
View user's profile Send private message
strafford
Smarty Rookie


Joined: 27 Jun 2018
Posts: 17

PostPosted: Thu Jun 28, 2018 3:59 pm    Post subject: Reply with quote

I am using a template variable to display everything.

As for your reference to https://www.smarty.net/docs/en/api.get.template.vars.tpl yes I can get the values, but I want to then assign/change the values. That is the part I cannot figure out.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jun 28, 2018 4:02 pm    Post subject: Reply with quote

Just assign a new value to the template.
Until you fetch the template content, it's all fair game.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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