How to Add a Button with link to new form in a Table

davebutner

New Member
Hey all,

I just started playing with Fabrik today for my site. It really looks nice. I have a nice joined table view that I want to modify.

I would like to eliminate the View link and replace it with a button that links to a form and passes the row information to the new form? Is this possible?

Thanks much in Advance,

Dave
 
I have been looking for some data about that too. Like if you click on a certain record it will go to another table or data set with just records from the foreign key column, etc.. :). I will keep playing, and let you know if I find anything close.
ab
 
Hi Dave,

To eliminate the view link you can set the access level to something more appropriate by going to the Joomla admin page and selecting Component/Fabrik/Table, choose the table you want to modify and select the "edit" button, select the "Access" tab and in the list available for "View Table" select which access level would be appropriate. In the element admin for a given group/form you can set the access level for any element to "Show in table view". This can be found under the "Table Settings" tab. You can use this feature to create a link from the table view to a forms detail info using the elements label. Any info available from a table row should be visiable in the form the table is attached to.

If I have missunderstood you questions please resate and send again.

Thanks for choosing Fabrik,
-Graylan King
 
I understand how to get rid of the view link, but not the second part about adding a link from the table view to a form using the element's label.

What would be perfect is a table view with each row having a button. The button should link to a form and pass the table row data to it.

Does that sound doable?

Thanks,

Dave
 
Hi Dave,

The data displayed in the table view is actually a reflection of data found in a form record. What is used as a "button" to link a table view to a form is the label of any given element - you get to choose which elements are displayed in the table view as well as what elements will link the table view to the form.

In your Joomla admin go to Components/Fabrik/Elements and use the "Group" drop-down filter to select the group which is used in the form you want to link to. This action will isolated the elements that are assigned to the group. If you have only one group this may not be nessesary, but is very useful when you have many groups and many elements.

You can now more easily identify an element that has a label you would like to use as a "button". Check the box to the left of the element and select the "edit" button. Now select the "Table Settings" tab found on the upper right of the page, then select "Show in table view" to show this element in the table view (deselect the check box to take an element out of the table view), next select "Links to detailed view" (to make the label of the element act as a "button" link from the table vew to the form view) and save.

Please make sure that you have created a menu link for the table, so you can view the table from the front end - I'm assuming you know how to do this :)

Thanks for choosing Fabrik,
-Graylan King
 
Graylan,

I've re-read your replies a few times now, and I don't think I explained it well. I believe your reply describes how to go to a form view, from a table view, when both are using the same underlying table.

What I want is to have a link on the table view that takes you to a form for a totally different table.

Like to have a table view of products and have a "Place Order" button on each row, which then when clicked on takes you to an Order Form for an Order Table, while passing the product info to the order form.

Anyone know how to do this?

Thanks,

Dave
 
Mr. King I have to think about what you said, but I have the same type of question, but instead of pointing to a form, I would like to point to a different table with a filter for the id or foreign key to a data set.

For example,
Table 1 -->
Student_info
Student_id
first_name
last_name
addr
etc...

Table 2 -->
class_info
student_id
class_attended
promotion_date
etc...

So in my question I have a table view of all the students in table 1. Now there is a button on each of these rows that "sends" the student_id (example = student_id=1) and will now pull the table 2 data results where student_id=1 (the posted data I would send from the data result button).

e.g. in pgp I had done this before with:

------------------------->
$result_id = mysql_query($query);
$column_count = mysql_num_fields($result_id)
or die("display_db_query:" . mysql_error()) ;

print("<TABLE BORDER=1>\n");
print("<TD>STD_ID</TD>\n");
print("<TD>NAME</TD>\n");
print("<TD>Rank</TD>\n");
print("<TD>WRank</TD>\n");
print("<TD>Hours(start_dt)</TD>\n");
print("<TD>Status</TD>\n");
print("</TR>\n");

while ($row = mysql_fetch_row($result_id))
{
print("<TR ALIGN=LEFT VALIGN=TOP>\n");

$FORM_VAL = $row[0];
print("<TD>\n");

print("<A HREF=\"./student_report.php?ID=$FORM_VAL\" TARGET=\"\">");
------------------------->
--> this is there it pointed to another page passing in the variable which the next page builds its "reports" off of for that specific user_id. Probabaly not the best way. Ideas?
 
Dave Butner said:
Graylan,

I've re-read your replies a few times now, and I don't think I explained it well. I believe your reply describes how to go to a form view, from a table view, when both are using the same underlying table.

What I want is to have a link on the table view that takes you to a form for a totally different table.

Like to have a table view of products and have a "Place Order" button on each row, which then when clicked on takes you to an Order Form for an Order Table, while passing the product info to the order form.

Anyone know how to do this?

Thanks,

Dave

Is there any answer to this? I really need to know if it can be done. Thanks.
 
I think you would need to write a custom template to do this.

Create a html file called "newtemplate.html" in /components/com_fabrik/tmpl/table/
Edit your products fabrik table so that newtemplate.html is selected as the table template

lets presume that your product database table is called "jos_products" and contains the following elements:
id
name

and that your order table contains a column
product_id

Edit newtempalte.html :
Code:
 <mos:tmpl name="named-groups" type="condition" conditionvar="rowcount">
	<mos:sub condition="0">
		{EMPTY_DATA_MSG} 
	</mos:sub>
	<mos:sub condition="__default">
		<mos:tmpl name="named-rows">
			
			
			<mos:var name="jos_products.name" />
             <a href="index.php?option=com_fabrik&fabrik=1&table_id=1&product_id[value]=<mos:var name="jos_products.id" />">ORDER</a>
            <br />
		</mos:tmpl>
		
	</mos:sub>
</mos:tmpl>
<mos:comment>

</mos:comment>
<mos:var name="fabrik_templatevars" />
 
Rob Clayburn said:
I think you would need to write a custom template to do this.

Create a html file called "newtemplate.html" in /components/com_fabrik/tmpl/table/
Edit your products fabrik table so that newtemplate.html is selected as the table template

lets presume that your product database table is called "jos_products" and contains the following elements:
id
name

and that your order table contains a column
product_id

Edit newtempalte.html :
Code:
 <mos:tmpl name="named-groups" type="condition" conditionvar="rowcount">
	<mos:sub condition="0">
		{EMPTY_DATA_MSG} 
	</mos:sub>
	<mos:sub condition="__default">
		<mos:tmpl name="named-rows">
			
			
			<mos:var name="jos_products.name" />
             <a href="index.php?option=com_fabrik&fabrik=1&table_id=1&product_id[value]=<mos:var name="jos_products.id" />">ORDER</a>
            <br />
		</mos:tmpl>
		
	</mos:sub>
</mos:tmpl>
<mos:comment>

</mos:comment>
<mos:var name="fabrik_templatevars" />


Rob, so now...how does the called form get the value of the &product_id? I imagine there is something that needs to be coded in the default value of the elements, but I cannot understand what the syntax would be?

Thanks,

Dave
 
Hi!

How can I use this to create new records with default values. I mean, when I click the link, I want the opened form prefilled with default values relatives to this record.

thanks in advance
 
Hi Jorge,

You can set default values at the element admin level. Go to your Joomla admin and select Component/Fabrik/Elements - choose an element you would like to have a default value set for an scroll to the bottom of the page - what ever the element is - you should see an area/field in which you can set a default.

Thank you for choosing Fabrik,
-Graylan King
 
Hi Graylan!!

Yes I've seen this property at design time, but I want to fill this value at runtime. Supose I have a row with some values in the table view at runtime (frontend). I want a button in this row that point to new record in other form with some values prefilled from this row.

Thxsss
 
How to Add a Button with link to new form in a Table (Table --> Details Table)

I added the new template, and got some weird restults, just curious with some feed back:

1)
My results are not coming out in table format (as normal), i probably should figure out what this data is doing then copy the default template after get idea.
2)
The link is pulling up a form and not a list to a table. I am wanting the "Link" to point to a new table list view with only the values for a specific student. I believe I am getting closer. What am I doing wrong (or the first few issues :)?
<a href="index.php?option=com_fabrik&fabrik=4&table_id=4&STUDENT_ID[value]=<mos:var name="STUDENT_INFO.STUDENT_ID" />

Thanks,
Andrew

Results on Page:

Blevins ORDER
(Persons Name..) ORDER <-- the ORDER is the "link" to the new page
(Persons Name..)ORDER
(Persons Name..)ORDER
(Persons Name..)ORDER
(Persons Name..)ORDER
(Persons Name..)ORDER
(Persons Name..)ORDER
(Persons Name..)ORDER
(Persons Name..)ORDER
STUDENT_INFO.STUDENT_ID = 1
STUDENT_INFO.FIRST_NAME = Andrew
STUDENT_INFO.LAST_NAME = Blevins
STUDENT_INFO.START_DATE = 2004-01-02
STUDENT_INFO.STATUS = current
CLASS_INFO.KR_RANK = KC
....... (data keeps going )

(TEMPLATE CODE)
<mos:tmpl name="named-groups" type="condition" conditionvar="rowcount">
<mos:sub condition="0">
{EMPTY_DATA_MSG}
</mos:sub>
<mos:sub condition="__default">
<mos:tmpl name="named-rows">


<mos:var name="STUDENT_INFO.LAST_NAME" />
<a href="index.php?option=com_fabrik&fabrik=4&table_id=4&STUDENT_ID[value]=<mos:var name="STUDENT_INFO.STUDENT_ID" />">ORDER</a>
<br />
</mos:tmpl>

</mos:sub>
</mos:tmpl>
<mos:comment>
 
I got it to work (with more info from this post) -->

<a href="index.php?option=com_content&task=view&id=72&Itemid=66&student_id[value]=<mos:var name="STUDENT_INFO.STUDENT_ID" />">ORDER</a>

However, looking at the standard template (which I would like to copy then modify as a different name), where could I put the above line to get it to work in lets say the first (column) of the result set rows: -->
(from template)

<!-- This is the template for all other rows -->
<tr class="oddrow{PAT_IS_EVEN}">
<mos:tmpl name="cell">
<td><mos:var name="value" /></td>
</mos:tmpl>
</tr>
</mos:sub>
<mos:sub condition="__last">
<!-- calculations column -->
<tr>
<mos:tmpl name="lastcell">
<td><strong><mos:var name="value" /></strong></td>
</mos:tmpl>
</tr>
</table>
</mos:sub>
</mos:tmpl>



-------------
Sorry :) & thanks for any ideas..
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top