Main Pages — Add Modal Field Types & Naming¶
Part of: Main Pages guide See also: Add Modal Structure | Delete Modal
Specifying Fields¶
When specifying Add modal fields in your prompt:
<ipa_attribute> → "<Label>" (<data_type>, <ui_component>, required|optional)
Available UI Components¶
UI component |
Import from |
Use when |
|---|---|---|
|
|
Required single-line text with validation helper |
|
|
Optional single-line text |
|
|
Multi-line text (use |
|
|
Boolean flags |
|
|
One-of-N choice |
|
|
Dropdown selection |
|
|
Numeric with increment/decrement |
|
|
Password with show/hide |
|
|
Simple dropdown |
|
|
Text with inline validation rules |
Field Validation with InputWithValidation¶
Use when fields have format constraints:
{
id: "modal-form-host-name",
name: "Host name",
pfComponent: (
<InputWithValidation
dataCy="modal-textbox-host-name"
id="modal-form-host-name"
name="modal-form-host-name"
value={hostName}
onChange={setHostName}
isRequired
rules={[
{
id: "valid-chars",
message: "Allowed characters are a-z, A-Z, 0-9, and -",
validate: (value: string) => /^[a-zA-Z0-9-]+$/.test(value),
},
]}
/>
),
fieldRequired: true,
}
Existing validation examples:
Entity |
Field |
Validation |
|---|---|---|
Hosts |
Host name |
|
Hosts |
IP address |
Valid IPv4 or IPv6 |
Users |
User login |
Alphanumeric and |
Naming Conventions¶
Element IDs (id)¶
modal-form-{field-name}
Examples: modal-form-user-login, modal-form-description
Test Attributes (data-cy / dataCy)¶
Component Type |
Pattern |
Example |
|---|---|---|
Text input |
|
|
Text area |
|
|
Checkbox |
|
|
Radio button |
|
|
Select/Dropdown |
|
|
Number input |
|
|
State Variables¶
Use camelCase, one useState per field:
const [userLogin, setUserLogin] = React.useState("");
const [description, setDescription] = React.useState("");
const [generateOtp, setGenerateOtp] = React.useState(false);
Handler Functions¶
Use on{Action} pattern:
const onAdd = () => { /* ... */ };
const cleanAndCloseModal = () => { /* ... */ };
Field Template¶
const fields: Field[] = [
{
id: "modal-form-<field-name>",
name: "<Label>",
pfComponent: (
<InputRequiredText
dataCy="modal-textbox-<field-name>"
id="modal-form-<field-name>"
name="<ipa-attribute>"
value={fieldState}
onChange={setFieldState}
requiredHelperText="Required value"
/>
),
fieldRequired: true, // omit for optional fields
},
];
Best Practices¶
Consistency: Use kebab-case for
idanddata-cyattributesUniqueness: Each
data-cyvalue must be unique within the modalDescriptive: Use clear names that indicate the field’s purpose
Match IPA attributes: Derive field names from IPA attribute (e.g.,
ipatokenowner→modal-form-owner)
Other Add Modal Examples¶
Entity |
Modal file |
Fields |
|---|---|---|
HBAC Rules |
|
Rule name, Description |
Hosts |
|
Host name, Description, Class, IP, Force, OTP |
Trusts |
|
Domain, Auth method, Admin, Passwords, Range type |
Users |
|
Login, First/Last name, Class, GID, Passwords |