Your form is defined by your XML form (typically located in models/forms). You choose to have the same names as those in your database as those field names but actually it isn't compulsory.
You can think of the table as being like a wrapper around a row to insert. You go through a 3 stage process.
bind
takes the array of data that comes from your form and then stores any data from it into the table class.
check
then runs sanity checks on the data that you have binded into the table class
store
then stores the binded data into the database table.
However what's important is the data that is stored in the class. This means that the names of the fields in your form are to an extent irrelevent. For example. You could have a field in your form called foobar
and then in your bind method do:
public function bind($src, $ignore = array())
{
$this->tableVar = $src['foobar'];
parent::bind($src, $ignore);
}
And this will try and store the foobar
variable from your form as a column called tableVar
in your database
EDIT:
This is because the parent bind method will bind data to the class as a class var
public function bind($src, $ignore = array())
{
foreach ($src as $field => $value)
{
$this->$field = $value;
}
}
and then will attempt to match $field
to a database column storing the value if it exists. So the importance of setting $this->tablevar
above is that is the column in your database was tablevar
and you didn't have a column called foobar then now it gets stored into the database.