Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Edit form still does not come up

JohnKlassen
Posts: 148
Joined: Wed Dec 05, 2012 4:56 am

Edit form still does not come up

Unread post by JohnKlassen »

Hi,

I previously had a post where I said that when I was in the browse screen and clicked on a record, the edit screen did not come up. I copied the below from that post.
I have created 6 tables with their corresponding browse and edit forms. When I am in the browse form and click on a record, the edit form does not come up. On the other hand if I click on the 'Add record' button, the form does come up to add a record.

I did not see anything in the video tutorials that said I needed to do anything special to cause the edit form to come up when clicking on a record in the browse form.
Since then I have done a fresh install using verison 2.8.1 (build 554) and once again added tables forms, etc. Although my other problems have gone away, I still do not get an edit form when I click on a record in the browse screen. Do I have to do anything special to get this feature to work? I have not selected any other form in the 'form to edit' option.

Any suggestions?

John
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Edit form still does not come up

Unread post by admin »

John,

Is this still happening on more than one screen?

Can you send me a copy of the html source code from the Browse Form?

That might have the answer.

Steven
JohnKlassen
Posts: 148
Joined: Wed Dec 05, 2012 4:56 am

Re: Edit form still does not come up

Unread post by JohnKlassen »

Steven,

Yes, this is still happening on more than 1 form. I have created 6 tables and a form for each table. This is happening for all 6 browse forms.

I have attached the source code for the form with the least number of rows.

I really appreciate your help on this.

John
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Edit form still does not come up

Unread post by admin »

John,

What values are being stored in the Form's Primary Key?
cap.PNG
Because it is coming up blank.

If you run SELECT Primary Key FROM Table eg SELECT transaction_id FROM transaction , in phpmyadmin, what do you get?

Steven
You do not have the required permissions to view the files attached to this post.
JohnKlassen
Posts: 148
Joined: Wed Dec 05, 2012 4:56 am

Re: Edit form still does not come up

Unread post by JohnKlassen »

Steven,

You are right. The primary key was blank and in fact was missing. I dropped the table and added the ‘PRMARY KEY’ option to the CREATE TABLE statement. It now looks like the following:

CREATE TABLE `agent` (
`agent_id` VARCHAR( 15) NOT NULL PRIMARY KEY ,
`building_unit` VARCHAR( 10)NOT NULL ,
`agent` VARCHAR( 25)NULL ,
`company` VARCHAR( 40)NULL ,
`phone` VARCHAR( 12)NULL ,
`address_1` VARCHAR( 40)NULL ,
`address_2` VARCHAR( 40)NULL ,
`city` VARCHAR( 25)NULL ,
`state` VARCHAR( 2)NULL ,
`zip` VARCHAR( 5)NULL ,
`email` VARCHAR( 40)NULL
) ENGINE=MYISAM COMMENT='agent';

Now I am running into some issues with reloading the data. My client sends me the data in a spreadsheet which I then convert to a CSV file. I was using 'CSV using LOAD DATA' under the 'Import' tab to load my data, Now that I have defined a Primary Key, this is no longer working. It would only load the first row and the primary key would be blank. In the CSV file, the first data line looks like this:

“","04-204","Jan","Management Company","303-555-6206 ","3206 Main St.","","Denver","CO","80129",""

I tried entering data through the Insert option in phpMyAdmin. Although it created the row, there was nothing in the Primary key field.

I then removed the form and its objects and recreated it. I clicked on add record. I was able to add the record and click on Save. When I went back to phpMyAdmin, the record I added does have a primary key so I know I am on the right track. When I click on the record in the browse screen, it does bring up the record in the Edit form.

It comes down to 2 questions. What is the best way to load my data into a table when there is a primary key? Secondly, can you please give a little explanation on how the primary key is generated?

I was hoping to show the browse/edit feature to my client tomorrow morning and it would be nice to have reloaded their data using the primary key.

Thanks for all of your help.

John
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Edit form still does not come up

Unread post by admin »

John,

It only imports the first record because Primary Keys need to be unique, so it won't import 2 records with blank ids.

Maybe create them in Excel first..
cap.PNG
Steven
You do not have the required permissions to view the files attached to this post.
JohnKlassen
Posts: 148
Joined: Wed Dec 05, 2012 4:56 am

Re: Edit form still does not come up

Unread post by JohnKlassen »

Steven,

Now I am confused. I was under the impression that the primary key was generated by NuBuilder. I already had unique values for the first column in each table, before I added the <table name>_id field and made it a primary key field. In my example, 'building_unit' has unique values. Can I make that the primary key? If yes, should I rename building _unit to agent _id?

John
JohnKlassen
Posts: 148
Joined: Wed Dec 05, 2012 4:56 am

Re: Edit form still does not come up

Unread post by JohnKlassen »

Steven,

After my last post, I did some more testing and ran into some new problems.

I created a new table called unit_agent with the following SQL statement:
CREATE TABLE IF NOT EXISTS `unit_agent` (
`unit_agent_id` varchar(10) NOT NULL,
`una_agent` varchar(25) DEFAULT NULL,
`una_company` varchar(40) DEFAULT NULL,
`una_phone` varchar(12) DEFAULT NULL,
`una_address_1` varchar(40) DEFAULT NULL,
`una_address_2` varchar(40) DEFAULT NULL,
`una_city` varchar(25) DEFAULT NULL,
`una_state` varchar(2) DEFAULT NULL,
`una_zip` varchar(5) DEFAULT NULL,
`una_email` varchar(40) DEFAULT NULL,
PRIMARY KEY (`unit_agent_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='agent assigned to unit';

As you can see the primary key is now unit_agent_id. I removed the first column in my CSV file (which had been blank) and reloaded the data. The new first colum had unique data and became my primary key. I had no problems with the load of the data.

I created a new form with browse and edit. Everything appeared to be working fine. When I clicked on a browse row, it popped up the edit screen. But when I tried the 'add record' and the 'clone' and went back to the browse screen, the only thing I saw was new rows with only a NuBuilder generated key despite entering a unique key for the 'add record' and the 'clone'.

What do you suggest?

John
JohnKlassen
Posts: 148
Joined: Wed Dec 05, 2012 4:56 am

Re: Edit form still does not come up

Unread post by JohnKlassen »

Steven,

Afte writing the last post I saw the following in another post called "What about foreign keys":
If you currently have PKs and FKs in any string format, nuBuilder will work with what you've got and just create uniqid() strings for new records.
Based on the above statement and my problems with 'add record' and 'clone', I am not sure how to handle the primary key issue. If I use my unique values for a primary key, that will only work with browse and edit. 'Add record' and 'clone' will create NuBuilder primary keys which defeats my using my own values for primary keys.

If I have NuBuilder handle the primary keys, how do I do a mass load of my data?

Thanks,

John
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Edit form still does not come up

Unread post by massiws »

John,

when you add a new record (or clone an existing one) nuBuilder create itself the PK for the record using uniqid() function (http://wiki.nubuilder.com/tiki-index.ph ... uilderDocs) so you don't have to manage it: you must only indicate the name of the field containing the PK in the Form General tab; in Reorder Form Objects tab you shouldn't have any PK object (no PK field visible on edit form).

To import data from a CVS file, you can run a little php script that read one by one records from CVS file, generate, for each record, a PK with uniquid() function and execute an INSERT query in your db.

Max
Locked