[solved] How to add a default field value to formbuilder using a variable?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
robbedoes
Forum Members
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?

Post 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?
Last edited by robbedoes on Fri Jan 23, 2009 8:05 am, edited 1 time in total.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: How to add a default field value to formbuilder using a variable?

Post by Nullig »

What about...

{cms_module module='FormBuilder' form='inschrijven' value_fld35="{$title}"}
robbedoes
Forum Members
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?

Post by robbedoes »

I tried it but without success,
The output is:



B.t.w. I use this in a page, not in a template.
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: How to add a default field value to formbuilder using a variable?

Post 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}
robbedoes
Forum Members
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?

Post 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:

robbedoes
Forum Members
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?

Post by robbedoes »

This will do the job:

In page content:

capture assign='defaultval'}{title}{/capture}

{cms_module module='FormBuilder' form='inschrijven' value_fld35="$defaultval"}
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: [solved] How to add a default field value to formbuilder using a variable?

Post by plger »

True enough, the title is not stored in $title but called in {title}
robbedoes, how about the simpler

Code: Select all

{title assign="title"}
to assign it to $title?
robbedoes
Forum Members
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?

Post by robbedoes »

plger wrote: True enough, the title is not stored in $title but called in {title}
robbedoes, how about the simpler

Code: Select all

{title assign="title"}
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???
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: [solved] How to add a default field value to formbuilder using a variable?

Post 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
robbedoes
Forum Members
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?

Post 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
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: [solved] How to add a default field value to formbuilder using a variable?

Post 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.
Post Reply

Return to “Modules/Add-Ons”