Get the values of the form fields from another module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

Get the values of the form fields from another module

Post by urheat »

Hi,

I have created multiple events with LISE. User can register to a event using a form (formbuilder). The form is mostly the same for all events, but the title (event title) and the dates (one event can have multiple dates) are different in every event.

So basically could I have just one form where:
- the value of title (text field) would be automatically fetched from the event data of the LISE event
- the values of the dates (Dropdown) would be automatically fetched from the event data of the LISE event.

Is it possible and if so, how?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Get the values of the form fields from another module

Post by Jo Morg »

urheat wrote:Is it possible and if so, how?
It's possible of course... keep in mind that this is basically a normal default LISE call, for instance on the top of form template do something like:

Code: Select all

{LISEMyTestModule assign=foo}
<pre>{$items|print_r:1}</pre>
You'll will see that the {$items} smarty var is still in scope, at least for the next minor versions of CMSMS. If (and when) that stops working at some point, you can still use that technique by making the {$items = $items scope=parent} on the used summary template of that LISE instance. In fact you can then use any smarty var you which to avoid conflicts with other variables from other templates....
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

Re: Get the values of the form fields from another module

Post by urheat »

Thanks Jo,

sorry for a newbie question but how can I print for example the title in a form. Tried too many ways ;) I mean something like this:

{LISEomamatkatuotanto assign=foo}
{$items->item->title}
<pre>{$items|print_r:1}</pre>

and in FormBuilder, how can I get the value? Is it the same syntax? For example if I have a Text Input, do I place the code to the "Smarty data or logic that is meant to be sent with this field":
{$items->item->title}

p.s. The LISE is just great!
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Get the values of the form fields from another module

Post by Jo Morg »

urheat wrote:{LISEomamatkatuotanto assign=foo}
{$items->item->title}
<pre>{$items|print_r:1}</pre>
That won't work exactly like that: you need to single out an item first and for that you need to know either the id or the alias (actually there are ways to return one record from a number of parameters but that is another advanced topic).
So, once you have an id or alias (and how you get it is up to you, depends on what you are trying to implement) then there are a few ways you can make that work:

Code: Select all

 
{LISEomamatkatuotanto action=detail item=$item_alias assign=foo}
Then you can use {$item} as you would in any LISE detail template.
Or not so efficient but still valid

Code: Select all

{LISEomamatkatuotanto include_items=$item_id_or_alias assign=foo}
Then you can do something like {$items[0]->title} etc...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

Re: Get the values of the form fields from another module

Post by urheat »

Thanks Jo,

just to make sure I've have appropriate way passing the alias. The detail page of the Lise object is the same page where the form is. I created global alias variable in Lise Detail template:

Code: Select all

{$items = $items scope=parent} 
{assign var='lisealias' value=$item->alias scope=global}
And in the FormBuilder Form Template:

Code: Select all

{LISEomamatkatuotanto action=detail item=$lisealias assign=foo}
{$item->title}
Is this ok? It works :)

And what is the most easiest/practical way to set the value of the specific form field. For example if I have text input form field and I would like to set the title of the Lise object to it's value...? Now I set it with jQuery, but I hope there is a way to do it without using scripts:

Code: Select all

<__script__>
$(document).ready(function(){
  $("#title").val("{$item->title}");
});
</__script>
All the above works. The real problem is that I don't have an idea how to create 1-* radio buttons depending how many items Lise object has. Every event has 1,2 or maybe 4 different dates. User should select one of the dates. So in the Form Builder form there should be the same amount radio buttons with the values of the Lise objects dates...
Post Reply

Return to “Modules/Add-Ons”