[solved] How to add a default field value to formbuilder using a variable?
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
[solved] How to add a default field value to formbuilder using a variable?
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?
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?
Last edited by robbedoes on Fri Jan 23, 2009 8:05 am, edited 1 time in total.
Re: How to add a default field value to formbuilder using a variable?
What about...
{cms_module module='FormBuilder' form='inschrijven' value_fld35="{$title}"}
{cms_module module='FormBuilder' form='inschrijven' value_fld35="{$title}"}
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: How to add a default field value to formbuilder using a variable?
I tried it but without success,
The output is:
B.t.w. I use this in a page, not in a template.
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?
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}
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: How to add a default field value to formbuilder using a variable?
Sorry, no resulting value when calling the formbuilder tag in {content}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}
output:
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: How to add a default field value to formbuilder using a variable?
This will do the job:
In page content:
capture assign='defaultval'}{title}{/capture}
{cms_module module='FormBuilder' form='inschrijven' value_fld35="$defaultval"}
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?
True enough, the title is not stored in $title but called in {title}
robbedoes, how about the simpler
to assign it to $title?
robbedoes, how about the simpler
Code: Select all
{title assign="title"}
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: [solved] How to add a default field value to formbuilder using a variable?
plger wrote: True enough, the title is not stored in $title but called in {title}
robbedoes, how about the simplerto assign it to $title?Code: Select all
{title assign="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?
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
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
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: [solved] How to add a default field value to formbuilder using a variable?
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
Thank you for the explanation!!!
Cheers,
Rob
Re: [solved] How to add a default field value to formbuilder using a variable?
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.
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.