Conditions in templates using values of elements

impalah

New Member
Hi everybody

I'm new with Fabrik (and in the forum, this is my first post) but in the past 3 or 4 days I was playing with the component and I think is really amazing.

After making some simple applications that work I need now to make the "presentation" and my problem beggins here.

I haven't found any way to use a element of a form to pass to a template condition, like this, for example:

Code:
<mos:tmpl name="showbuttons" type="condition" conditionvar="Group12_Logged_User_ID">
 <mos:sub condition="0">
  <h3>Please, log-in</h3>
 </mos:sub>
 <mos:sub condition="default">
  <h3>LogID: {GROUP12_LOGGED_USER_ID}</h3>
  <input type="submit" name="chekIt" class="button" value="Check" onclick="alert('My ID: ' + {GROUP12_LOGGED_USER_ID});"/>
 </mos:sub>
 <mos:sub condition="empty">
  Vacio???
 </mos:sub>
</mos:tmpl>

The pattemplate variable is GROUP12_LOGGED_USER_ID (its name in fabrik is Logged_User_ID).

Well, intention is to get Joomla $my->id and if it's different from zero display a button. I put this into an element of fabrik and works well to present it, but not for conditions.

Am I doing something bad?

Is there any other way to obtain "id" and use it in a condition?

What are the format of "fabrik elements" variables for pattemplate?

Thank you.
 
I am still stopped with this... Can anyone help me?

(I'll hate to use a javascript solution for this like I'm doing now).
 
hi

Couple of issues with your template, the one below works for me:

Code:
<mos:tmpl name="showbuttons" type="condition" conditionvar="Group12_Logged_User_ID_ro" varscope="body">
 <mos:sub condition="0">
 	<h3>Please, log-in</h3>
 </mos:sub>
 <mos:sub condition="__default">
 	 <h3>LogID: {GROUP12_LOGGED_USER_ID}</h3>
  <input type="submit" name="chekIt" class="button" value="Check" onclick="alert('My ID: ' + {GROUP12_LOGGED_USER_ID});"/>
 </mos:sub>
 <mos:sub condition="__empty">
  Vacio???
 </mos:sub>
</mos:tmpl>

note the "varscope="body"" in the template - this tells pattemplate to look for the condition variable in the body of the template and not just within the template "showbuttons".
Then note that the test variable is "Group12_Logged_User_ID_ro" and not "Group12_Logged_User_ID", this is because "Group12_Logged_User_ID" contains the html code to render the form's element, whereas the "_ro" (read only) version contains simply the value of that form's element.

Finally note that the default condition tests are all prefixed with "__"

Also check out this similar thread, where I explain why a custom template might not be necessary http://fabrikar.com/index.php?option=com_smf&Itemid=9&topic=449.0

Cheers
Rob
 
Thank you Rob, it works!!!

I've read the post about permisions but it's not the case here. I needed to put a button that affects the whole application (extending Jobs tutorial) where a user can "apply" for a job directly without editing any form. If the user is logged in, then the button only write his userId on a Offer/appliances relationship table.

Thank you very much
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top