Current Record: tab #48

tab directive of the fields.ini file Table of Contents tab directive of the fields.ini file Example 1: Placing address info on separate ...

Current Record: tab #48

tab directive of the fields.ini file Table of Contents tab directive of the fields.ini file Example 1: Placing address info on separate ...

tab

[Permalink]

tab directive of the fields.ini file

The tab directive of the fields.ini file specifies which tab of the record edit form a field should be displayed on. Xataface supports multiple tabs on the edit form by way of this tab directive. If no fields contain the tab directive then all fields are displayed in a single tab (named __main__).

Example 1: Placing address info on separate tab

Consider the following people table:

CREATE TABLE `people` (
    person_id int(11) not null auto_increment primary key,
    first_name varchar(32) not null,
    last_name varchar(32) not null,
    address varchar(100),
    city varchar(100),
    province varchar(100),
    country varchar(100),
    postal_code varchar(20)
)

We want to split the fields into two tabs:

  • Personal Info
  • Address Info

Splitting form into tabs

We'll do this in two steps. We use the tab directive to assign all address-related fields to the address_info tab. In the tables/people/fields.ini file:
[address]
    tab=address_info

[city]
    tab=address_info

[province]
    tab=address_info

[country]
    tab=address_info

[postal_code]
    tab=address_info

Now, when we load the edit form of the people table, we see two tabs:

  • __main__
  • address_info

__main__ is the name assigned to the default tab (for all fields that don't have a tab defined explicitly.

Customizing the tab labels

Next we will customize the tab labels by adding the following to the beginning of the fields.ini file:

[tab:__main__]
    label="Personal Information"

[tab:address_info]
    label="Address Information"

Reordering the tabs

If we want to reorder the tabs so that the address_info tab comes first, we would just reorder the definitions of the tabs:

[tab:address_info]
    label="Address Information"

[tab:__main__]
    label="Personal Information"

Try This Example App

You can try this tiny sample application out here.

blog comments powered by Disqus
Powered by Xataface
(c) 2005-2024 All rights reserved