How to pass value on "Add" button

Talk about implementing of customized templates

Moderators: ne_moj, zewa

billy2010
Junior
Junior
Posts: 10
Joined: Dec 10th, '10, 19:17

How to pass value on "Add" button

Postby billy2010 » Dec 21st, '10, 18:21

Pardon me if similar question has been answered before, I searched around and havn't found that.

The case likes this:

Database has three tables: company, product, company_has_product(company_id, product_id, date_added).

In Datagrid, I have a master table about companies. Each row is a company. There are several columns and one is "products", listing the count of product of certain company.

I set the count of products as a link to details table. When I click that, a sub table will bump out, listing the products the company have.

I want to click "add" button to add new relationship, i.e. to add a row in company_has_product. I have tweaked the add/edit part of details table(product), so this function works.

Now the problems comes. When turning to the add form of details table, I have to pick both product and company manually.

I want to pass the parameter of company so that in the Add form I only need to pick product. The master table has already sent this parameter to details table(I set $company = $_GET('pr_rid').

However this variable can't be passed to Add form. I set the field of company in Add/Edit form as "default"=>$company. But that doesn't work.

Is there a way to do that?

Thanks!

administrator
Site Admin
Site Admin
Posts: 5937
Joined: Jan 7th, '09, 23:18
Contact:

Re: How to pass value on "Add" button

Postby administrator » Dec 22nd, '10, 10:17

If you don't need to select company in Add mode, don't show dropdown or something else there.
If a company id is pre-defined , you may use hidden field instead of "default"=>$company

billy2010
Junior
Junior
Posts: 10
Joined: Dec 10th, '10, 19:17

Re: How to pass value on "Add" button

Postby billy2010 » Dec 22nd, '10, 17:34

Thanks admin!

I finally get it done due to another two reasons.

1. I have not set "AnotherDatagrid" before. So the variable can't be passed when handling details table.

2. The another is, I set the default postback as GET, but Add button use POST to send variable. So I set the variable to receive POST value in details table.

Code: Select all

$company_id = (isset($_POST['pr_rid'])&& $_POST['pr_rid']!='') ? $_POST['pr_rid'] : "";


As to the edit form type, since I want to review the value too, I used "label". But "label" type won't save the field to database, so I switch to textbox and set default value, it works.

Thanks!

rssridhar17
Junior
Junior
Posts: 21
Joined: Dec 8th, '11, 05:01

Re: How to pass value on "Add" button

Postby rssridhar17 » Dec 21st, '11, 05:35

Hi Billy,

To understand better what you meant by the 2 postings, can you share the online link where we can see the outcome of your fixing the issue, because even I have a similar issue.

I have 2 tables, one is Header_table and another is details_table.
Transaction-Add mode: 1 record would be entered for header_table and more than 1 record would be entered in details_table.
condition is: without adding record for details_table the add button in header_table should not be accepted.

Is it more like this, kindly share your online link to see the same.


Return to “Add/Edit/View Mode Templates Implementing”