Search in sources :

Example 61 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class ContentTypeHandlerTest method getExampleForm.

private Form getExampleForm() {
    Input name = Input.create().name("name").inputType(InputTypeName.TEXT_LINE).label("Full name").required(true).build();
    Input photo = Input.create().name("title").inputType(InputTypeName.IMAGE_SELECTOR).label("Photo").helpText("Person photo").required(true).build();
    Input bio = Input.create().name("bio").inputType(InputTypeName.HTML_AREA).label("Bio").required(true).build();
    Input email = Input.create().name("email").inputType(InputTypeName.TEXT_LINE).label("Email").helpText("Email address").required(true).inputTypeConfig(InputTypeConfig.create().property(InputTypeProperty.create("regexp", "^[^@]+@[^@]+\\.[^@]+$").build()).build()).build();
    Input birthdate = Input.create().name("birthdate").inputType(InputTypeName.DATE).label("Birth date").required(false).build();
    Input nationality = Input.create().name("nationality").inputType(InputTypeName.CONTENT_SELECTOR).inputTypeProperty(InputTypeProperty.create("allowContentType", "com.enonic.myapp:country").build()).label("Nationality").build();
    return Form.create().addFormItem(name).addFormItem(photo).addFormItem(bio).addFormItem(birthdate).addFormItem(email).addFormItem(nationality).build();
}
Also used : Input(com.enonic.xp.form.Input)

Example 62 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class ContentTypeHandlerTest method getForm.

private Form getForm() {
    Input myTextLine = Input.create().name("myTextLine").inputType(InputTypeName.TEXT_LINE).label("My text line").customText("Some custom text").helpText("Some help text").required(true).inputTypeConfig(InputTypeConfig.create().property(InputTypeProperty.create("regexp", "\\b\\d{3}-\\d{2}-\\d{4}\\b").build()).build()).build();
    Input myCustomInput = Input.create().name("myCheckbox").inputType(InputTypeName.CHECK_BOX).label("My checkbox input").required(false).defaultValue(InputTypeDefault.create().property(InputTypeProperty.create("default", "checked").build()).build()).build();
    final InputTypeProperty option1 = InputTypeProperty.create("option", "Option One").attribute("value", "one").build();
    final InputTypeProperty option2 = InputTypeProperty.create("option", "Option Two").attribute("value", "two").build();
    Input radioButtonInput = Input.create().name("myRadioButton").inputType(InputTypeName.RADIO_BUTTON).label("Radio button").inputTypeConfig(InputTypeConfig.create().property(option1).property(option2).build()).build();
    FieldSet myFieldSet = FieldSet.create().name("myFieldSet").label("My field set").addFormItem(Input.create().name("myTextLineInFieldSet").inputType(InputTypeName.TEXT_LINE).label("My text line").required(false).build()).build();
    FormItemSet myFormItemSet = FormItemSet.create().name("myFormItemSet").label("My form item set").addFormItem(Input.create().name("myTextLine").inputType(InputTypeName.TEXT_LINE).label("My text line").required(false).build()).build();
    final FormOptionSet formOptionSet = FormOptionSet.create().name("myOptionSet").label("My option set").helpText("Option set help text").addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption1").label("option label1").helpText("Option help text").addFormItem(Input.create().name("myTextLine1").label("myTextLine1").inputType(InputTypeName.TEXT_LINE).build()).build()).addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption2").label("option label2").helpText("Option help text").addFormItem(Input.create().name("myTextLine2").label("myTextLine2").inputType(InputTypeName.TEXT_LINE).build()).build()).build();
    return Form.create().addFormItem(myTextLine).addFormItem(myCustomInput).addFormItem(radioButtonInput).addFormItem(myFieldSet).addFormItem(myFormItemSet).addFormItem(formOptionSet).build();
}
Also used : FormOptionSet(com.enonic.xp.form.FormOptionSet) Input(com.enonic.xp.form.Input) FieldSet(com.enonic.xp.form.FieldSet) InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) FormItemSet(com.enonic.xp.form.FormItemSet)

Aggregations

Input (com.enonic.xp.form.Input)62 Test (org.junit.jupiter.api.Test)47 Value (com.enonic.xp.data.Value)24 Form (com.enonic.xp.form.Form)15 PropertyTree (com.enonic.xp.data.PropertyTree)11 FormItem (com.enonic.xp.form.FormItem)9 FormItemSet (com.enonic.xp.form.FormItemSet)9 FormDefaultValuesProcessor (com.enonic.xp.form.FormDefaultValuesProcessor)7 ContentType (com.enonic.xp.schema.content.ContentType)7 FormOptionSet (com.enonic.xp.form.FormOptionSet)5 FieldSet (com.enonic.xp.form.FieldSet)4 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)4 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)4 Property (com.enonic.xp.data.Property)3 Occurrences (com.enonic.xp.form.Occurrences)3 Content (com.enonic.xp.content.Content)2 ExtraData (com.enonic.xp.content.ExtraData)2 ValidationErrors (com.enonic.xp.content.ValidationErrors)2 PropertyPath (com.enonic.xp.data.PropertyPath)2 PropertySet (com.enonic.xp.data.PropertySet)2