Database Table & Form
The database
Hope you're not feeling too ambitious at the moment, because this is going to be a very simple demonstration table. It's going to have just three columns:
- uid
- A unique ID that's the primary key for the table. We'll make it auto-increment so that our SQL server (MySQL in this case) will do the work of keeping it unique.
- string1
- A simple string.
- string2
- Another simple string.
Create a test database and then the table. In MySQL, the CREATE code to set up the table is:
CREATE TABLE simple_db (
uid bigint(20) unsigned NOT NULL auto_increment,
string1 varchar(255) NOT NULL default '',
string2 varchar(255) NOT NULL default '',
PRIMARY KEY (uid)
) TYPE=MyISAM;
Now, set up an SQL user with privileges adequate to select, insert and update the table. Use that user identity to set up an SQL database connection object via the ZMI. (If you're using MySQL, this would be a Z MySQL Database Connection.) The connection must be in a place where it will be visible to the form you'll be creating.
The form
Now, create a PloneFormGen form with three fields:
- uid
- An string field with id uid, marked hidden, with a default value of "-1". Later in the tutorial, we'll use the "-1" as a marker value to indicate a new record.
- string1
- A string field with id string1.
- string2
- A string field with id string2.
While you're at it, turn off or delete the mailer action adapter. It's harmless, but it would be a distraction.
That's it. We now have a form that matches our database table.