|Data Entry with Xataface|
|Written by Nikos Vaggalis|
Page 2 of 3
Inserting a new record
So let's add a new Brand item. We simply have to click Brand on the top left of the interface so we navigate to the relevant section, then New Entry and finally filling the form with the value Linx:
Associating a Brand with a Model
The fun part is that we can then associate the newly created Brand record to a Model record when building such a Model (tablet or smartwatch) by selecting it from a list:
That is part of the story however. To enable such a relationship there is some tweaking to be done. It's where we need to fill the .ini files inside Model's directory. So we create the following files inside the Model directory:
widget:type = select
vocabulary = Brands
We tell Xataface to create a form field with a widget of type Select (which is going to be rendered as a HTML selection list),call it [Brand_BrandId], and instruct it to be filled with values from the Brands vocabulary.
__sql__ = "SELECT BrandId,BrandName from Brand"
This populates the select list with the Brand Names as in the picture above which shows a list of all the Brand Names existing in the Brand table, but selecting just Linx from the available options. Xataface is smart enough to display the character based column of the table (Brand Name) but underneath refer to it with a numeric Brand Id
A more complex example
Let's now move to a more complex example and colour to our Linx tablet through the use of the checkbox widget. We first create each colour in the Color table:
We append the following into fields.ini of the ModelColor directory:
__sql__ = "SELECT ModelColor.*,ColorName from
Then we append the following to the Model's directory files:
widget:type = checkbox
entries for valuelists.ini,which fill the checkboxes :
__sql__ = "SELECT ColorId,ColorName from Color"
We depict the Model to Color m:n relationship through the joint ModelColor table inside the relationships.ini file:
__sql__ = "SELECT * from Color,ModelColor
where Color.ColorId=ModelColor.Color_ColorId and
This instructs Xataface to update the intermediate ModelColor joint table with a Model_ModelId value and its associated Color_ColorID.
So this what the final site depicts: