required

required forces the user to enter data into the form field during an INPUT statement:

Form XML code:

<Calendar ... required="true"/>
By default, the property is set to false and is absent from the form XML code. The property value will appear in the form XML code only once the property value is set to true.

Possible values:

true, false

Default value:

false

Associated widgets:

CheckBox

ComboBox

Calendar

FunctionField

RadioGroup

TextArea

TextField

TimeEditField

Associated 4gl statements:

INPUT

Associated ui methods:

setRequired

getRequired

Influence and behavior:

If required is set to TRUE for a form field, you must enter some value into this field during an INPUT statement.

Otherwise, you will not be able to press the Accept button (to submit your input) and will get an error message:

lycia form designer:

4gl code sample:

MAIN
DEFINE f1, f2 STRING
OPEN WINDOW w WITH FORM "required" ATTRIBUTE(BORDER)
INPUT BY NAME f1, f2
END MAIN

runtime behavior:

 

If you set a default value for the field with required = TRUE, you don't need to change it – as this default value satisfies the required property:

 

Unlike notNull, required accepts NULL as an input:

 

At runtime, you can use the ui method – setRequired() – to force the user to enter data in the form field during an INPUT statement:

LET widget_var = ui.<widget>.ForName("widget_id1")

CALL widget_var.setRequired(...)

4gl example program:

MAIN
DEFINE f1, f2 STRING
DEFINE cld1, cld2 ui.Calendar

OPEN WINDOW w WITH FORM "required_ui" ATTRIBUTE(BORDER)
LET cld1 = ui.Calendar.ForName("f1")
LET cld2 = ui.Calendar.ForName("f2")
CALL cld1.setRequired(1)
CALL cld2.setRequired(0)
INPUT BY NAME f1
INPUT BY NAME f2
END MAIN

runtime behavior:

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.