Page 1 of 1
[solved] How to add a default field value to formbuilder using a variable?
Posted: Thu Jan 22, 2009 5:33 pm
by robbedoes
I'm trying to add a default field value to formbuilder using the title tag.
I tried this:
{cms_module module='FormBuilder' form='inschrijven' value_fld35="$title"}
and this:
{cms_module module='FormBuilder' form='inschrijven' value_fld35="{title}"}
But without any success.
This is working fine:
{cms_module module='FormBuilder' form='inschrijven' value_fld35="tryitbaby"}
What am I doing wrong?
Re: How to add a default field value to formbuilder using a variable?
Posted: Thu Jan 22, 2009 6:37 pm
by Nullig
What about...
{cms_module module='FormBuilder' form='inschrijven' value_fld35="{$title}"}
Re: How to add a default field value to formbuilder using a variable?
Posted: Thu Jan 22, 2009 8:18 pm
by robbedoes
I tried it but without success,
The output is:
B.t.w. I use this in a page, not in a template.
Re: How to add a default field value to formbuilder using a variable?
Posted: Thu Jan 22, 2009 9:43 pm
by plger
As you are already in a smarty tag, no need to add other ones :
Code: Select all
{cms_module module='FormBuilder' form='inschrijven' value_fld35=$title}
Re: How to add a default field value to formbuilder using a variable?
Posted: Fri Jan 23, 2009 7:31 am
by robbedoes
plger wrote:
As you are already in a smarty tag, no need to add other ones :
Code: Select all
{cms_module module='FormBuilder' form='inschrijven' value_fld35=$title}
Sorry, no resulting value when calling the formbuilder tag in {content}
output:
Re: How to add a default field value to formbuilder using a variable?
Posted: Fri Jan 23, 2009 8:04 am
by robbedoes
This will do the job:
In page content:
capture assign='defaultval'}{title}{/capture}
{cms_module module='FormBuilder' form='inschrijven' value_fld35="$defaultval"}
Re: [solved] How to add a default field value to formbuilder using a variable?
Posted: Fri Jan 23, 2009 8:30 am
by plger
True enough, the title is not stored in $title but called in {title}
robbedoes, how about the simpler
to assign it to $title?
Re: [solved] How to add a default field value to formbuilder using a variable?
Posted: Fri Jan 23, 2009 11:27 am
by robbedoes
plger wrote:
True enough, the title is not stored in $title but called in {title}
robbedoes, how about the simpler
to assign it to $title?
Great, this is working also. Thanks!!!
I don't understand why I have to assign the value.
If I add {title} to the content, the titled is printed.
When I use $title as a value in a tag (formbuilder) it does nothing at all???
Re: [solved] How to add a default field value to formbuilder using a variable?
Posted: Fri Jan 23, 2009 11:59 am
by plger
I'll try to explain to the best of my knowledge...
Like php in general, the "$" symbol denotes a variable. So {$varname} prints the content of a variable. If there are no "$", like in our case, it means that it's not a variable but a function which is processed. So when you run {title}, or any call to a module or UDT (or any tag, for that matter), there's a portion of code which is executed.
Even if you could call a function inside a smarty tag (which, although I haven't tried, I'm pretty sure you can't - smarty isn't exactly php), the function doesn't return the title, it just prints it (unless you use the assign parameter, in which case it's stored).
So you have to assign your title first.
Now the real question would be : why did the cms guys chose to make the title accessible through a function instead of a variable?
There's probably a reason (big sophism, but probably true), maybe to make sure nobody fooled around and overwrote the variable value.
But I don't know.
The page title might, however, be also stored in a variable... you can try {get_template_vars} and you'll see all the variables available through smarty.
Plger
Re: [solved] How to add a default field value to formbuilder using a variable?
Posted: Fri Jan 23, 2009 12:35 pm
by robbedoes
I totally misunderstood but of coarse {title} isn't a var. Now I understand why I have to use assign sometimes.....
Thank you for the explanation!!!
Cheers,
Rob
Re: [solved] How to add a default field value to formbuilder using a variable?
Posted: Thu Nov 19, 2009 11:01 pm
by davidjon
I know this topic hasnt been used in a while, but i hope someone can help me
Im having a bit of the same problem.
I used the capture method. however the output in the field is still $defvalue
what could be the reason of this happening.