This page is for application designers who want to vary the formatting of components depending on conditions.
Formatting rules are used Sometimes you want to vary the style of a component depending on some condition. For example, for a form field that:
- has data, you want to apply a style that displays the field background in green
- does not have data, you want to apply a style that displays the field background in red.
Use a formatting rule to determine when a style should be applied to an object. For example, highlighting a form field with a missing entry or changing an icon based on the selected company's industry sector.
For information about all the available options see Formatting Rule
All Formatting Rules perform a logic check that if it returns True the shared style will be applied.
Example - Highlight a Cellcomponent as follows:
- Open the properties for a component or attribute.
- In the Formatting Rule section, click ; see the Formatting Rule properties for details of all options.
- Enter a Rule Expression to perform a logic check of the data.
- Specify a style. If the expression returns
True
, this style overrides any existing style on the component.- Either select an existing style in the Style box drop-down list.
Alternatively, open the repository to find a style and drag it into the Style box. - Or create a new style, set its properties and save it.
PhixFlow automatically adds a new style to the Style box.
- Save the formatting rule.
Insert excerpt |
---|
| _refresh |
---|
| _refresh |
---|
nopanel | true |
---|
|
the screen, or close and reopen the screen to see the formatting rule applied to the screen.
This page shows how to use formatting rule expressions and styles:
In this example we will set the colour of a cell in a grid where the value is null as illustrated below:
Image RemovedSelect the column header and its properties open. In the screenshot below, the null cells are shown in red.
Image Added
Example - Highlight a Field- In the grid header, click a column header to open the attribute properties.
- In the Formatting Rule section, click . PhixFlow opens the new formatting rule properties.
- In the Enter a Rule Expression, in our .
For this example we want to apply a style to be applied when the a Web field cell is empty. To do this enter the expression:
_current.Web
==
_NULL
where _current
is used to make checks if each row check its has a value. Next we set the style that should be applied - Either select a style you want to use, or create a style to apply when the expression is true. Next to the Style drop-down, click next to the Style box and we will add a new style.If you have a style already that you wish to use, click . In Basic Settings, set:
- a Name for the style.
- Background Colour: #BF0426.
- Click
style_liststyle_list, navigate to it and drag your style into the style box. - Enter a Name.
- Enter #BF0426 in the background colour.
- Save your changes
- Save your Formatting Rule changes.
Now where the Web field is empty the cell will be highlighted red.
- Phixflow automatically adds the new style to the formatting rule → Style.
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save the formatting rule.
Refresh or reload the page to show the grid with the empty cells of the Web column highlighted in red.
In this example we will set the border of an input for to be red where the value is empty as illustrated below:
Image Modified
Select the input field
- In the screen canvas, click a field component to open its properties.
- In the Formatting Rule section click .
In the - Enter a Rule Expression
, in our - .
In this example we want a style to be applied when the field is empty. To do this enter the expression:
_value
==
_NULL
where _value
checks - checks the value in the form field.
Next we set the style that should be applied - Either select a style you want to use, or create a style to apply when the expression is true.
- Next to the Style drop-down, click
next to the Style box and we will add a new style.If you have a style already that you wish to use, click - . In the style properties → Basic Settings, set:
- Name, for example
MandatoryField
. - Border Style: Solid.
- Border Width:
1px
- Border Colour:
#BF0426
. - Click
style_list
style_list
, navigate to it and drag your style into
boxExample - Set an Icon
Enter:- Name, something indicative of the style e.g. Mandatory form Field.
- Border Style, Solid.
- Border Width, 1px.
- Border Colour, #BF0426.
Save your changesSave your Formatting Rule changes.Close and reopen the screen and the formatting rule will be applied.- Phixflow automatically adds the new style to the formatting rule's Style.
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save the formatting rule.
In this advanced example we will set an icon on a card component based on the industry field of our record as illustrated below:
Image RemovedImage Added
We need a screen setup that The screen illustrated above has a card container backed by company data. On
our the card we expect a field called Industry
which we will check in our formatting rule to determine which icon to display.Upload . We want to display a different icon for each industry.
- Upload the images that you want to use as your icons
, - ; see Adding Images
for details on how to achieve this.- .
- Create an area on your card component where you will display the images. We will call this
area Icon Area. Set it to be the desired size, for example height and width 30px each- the icon area.
- Open the properties for the
Icon Area.We will set a default icon and image settings. We do this so - icon area component.
- Set the area component's size to be suitable for an icon, for example with a Height and Width of 30px.
- To ensure there is never a blank
space where an icon should be and we only need to set the image settings once. This can be done directly on our area or within a shared style.- icon area, select an image to display be default. Use
Insert excerpt |
---|
| _property_tabs |
---|
| _property_tabs |
---|
name | style |
---|
nopanel | true |
---|
|
→ Style Settings of
- either a shared style; see Screen Styling
- or directly in the component properties
- Set:
, Select - : select the image that you want to be
our - the default image if none of the formatting rules are true.
- Background Repeat
, - : None.
- Background Position
, center- : Center.
This is CSS so we use the American spelling. - Background Size
, contain
Contain
Contain scales the image as large as possible within its container without cropping or stretching the image.
We can - Alternatively, specify a size in px.
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save the shared style or component.
The following formatting rule checks the industry to determine which icon to display. Create a formatting rule for each of the icons.
- In the Formatting Rule section, click .
In the - Enter a Rule Expression
, in our example we want a style to be applied when a specific industry is populated in the industry field- .
We want to check which industry is on the card to determine which icon to display. To do this enter:
_form.Industry
==
"Finance"
where _
form.Industry form
checks for the specified value in the
form -
Industry
field
Industry- .
- Create a style to apply when the expression is true. Next to the Style drop-down, click
next to the Style box and we will add a new style.Enter:- Name, indicative of the style e.g. Finance Icon.
- Background Image, set this to be the icon you wish to show when this expression is true.
- Save your changes.
Save your Formatting Rule changes.Repeat step 5 to create the formatting rules for each of the icons you wish to setup.This configuration is available to see in the Contact Manager demo app available from Downloads. See the Companies section- . In the style properties → Basic Settings, set:
- Name: for example
FinanceIcon
. - Background Image: select the icon to represent finance.
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save the style.
- Phixflow automatically adds the new style to the formatting rule's Style.
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save the formatting rule.
Tip |
---|
You can see an example of this configuration in the Contact Manager demo application (Companies section), which you can download from the Learning Centre Downloads page. |