CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Save 2 Forms clicking on 1 button

Print topic Send  topic

Author Message
manuel

Posts: 48
Posted: 04/05/2013, 4:13 PM

Hi, I have a Record Form and a Editable Grid in one page, it is possible to save changes on both using only one Submit/Save button?
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 04/05/2013, 8:46 PM

Is the idea to create a master record using the form for a one to many relationship using the editable grid as the many?
_________________
Central Coast, NSW, Australia.

View profile  Send private message
manuel

Posts: 48
Posted: 04/16/2013, 8:40 PM

Yes, that exactly the case. But the examples given by codecharge forced the user to save one form first, and then the other.

the value in common for each form (relationship) is a $variable, so its available when the page is loaded. In the examples the relationship is made using a value from the first form.
View profile  Send private message
manuel

Posts: 48
Posted: 04/16/2013, 8:45 PM

I forgot to mention that I'm using a Record and a Editable Grid
View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 04/17/2013, 1:34 AM

Summary...

This solution will produce a proper master/detail solution however it is different from an editable grid in that an editable grid will hold all it's values in memory until insert, while this solution writes the detail record line by line into the database and reconciles it with a master ID when all detail records are created and then the master record...

Solution Abstract...

I have a master/detail solution using 2 record forms, two grids, and set a random session variable in the before show event of the master record when master record is in add mode only.

To create a detail record I select from a grid, and using it's POST parameters I write using the detail record form by ADD(insert) straight into the database line by line and insert this session variable to ultimately link these detail records with the master record.

I then have another grid which shows the detail records which have been created (grid displays and retrieves based on the session variable) and I can click it and use yet another form after that which receives the detail record POST value and then a custom button running a delete script on that POST value if I don't want to keep the record.

Then, after ADD/inserting the master record - In the after insert event of this master record I retrieve the mysql_insert_id() for the master and then run a custom update script which locates all the detail records with the session variable as the link and update another detail record field with the mysql_insert_id() of the master thus creating a proper link between the master and the detail records using the mysql_session_id() . When this is finished I run another script to remove the session variable from the detail records to keep the database clean and I unset the session variable.

There are other things which then come into question such as what to do when a whole lot of detail records are created but form some reason the master is not added, we can address this when you get there.

I will likely dissect my web page and post a more comprehensive solution but it won't be for about four weeks.

Please let me know if this makes sense or more info required...
_________________
Central Coast, NSW, Australia.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.