use of com.enonic.xp.form.Form in project xp by enonic.
the class InputValidationVisitorTest method validateOptionSetValid.
@Test
public void validateOptionSetValid() throws Exception {
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();
Form form = Form.create().addFormItem(formOptionSet).build();
PropertyTree propertyTree = new PropertyTree();
propertyTree.setString("myOptionSet.myOptionSetOption1.myTextLine1", "33");
final InputValidationVisitor validationVisitor = new InputValidationVisitor(propertyTree, InputTypes.BUILTIN);
validationVisitor.traverse(form);
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class OccurrenceValidatorTest method testOptionSetWithUnlimitedNumberAllowedSelections.
@Test
public void testOptionSetWithUnlimitedNumberAllowedSelections() {
Form form = Form.create().addFormItem(FormOptionSet.create().name("options").label("Option tests").multiselection(Occurrences.create(0, 0)).occurrences(Occurrences.create(1, 1)).addOptionSetOption(FormOptionSetOption.create().name("a").label("A").build()).addOptionSetOption(FormOptionSetOption.create().name("b").label("B").build()).build()).build();
ContentType contentType = ContentType.create().name("myapplication:my_type").superType(ContentTypeName.structured()).form(form).build();
Content content = Content.create().path(MY_CONTENT_PATH).type(contentType.getName()).build();
PropertySet propertySet = new PropertySet();
propertySet.setProperty("a", ValueFactory.newString("Value A"));
propertySet.setProperty("b", ValueFactory.newString("Value B"));
content.getData().setSet("options", propertySet);
final ValidationErrors validationResults = validate(content);
assertFalse(validationResults.hasErrors());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class BuiltinMacroDescriptors method generateDisableMacroDescriptor.
private MacroDescriptor generateDisableMacroDescriptor() {
final MacroKey macroKey = MacroKey.from(ApplicationKey.SYSTEM, "disable");
final Form form = Form.create().addFormItem(createTextAreaInput("body", "Contents", macroKey).occurrences(1, 1).build()).build();
return create(macroKey, "Disable macros", "Contents of this macro will not be formatted", form);
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class BuiltinMacroDescriptors method generateEmbedIFrameMacroDescriptor.
private MacroDescriptor generateEmbedIFrameMacroDescriptor() {
final MacroKey macroKey = MacroKey.from(ApplicationKey.SYSTEM, "embed");
final Form form = Form.create().addFormItem(createTextAreaInput("body", "IFrame HTML", macroKey).occurrences(1, 1).build()).build();
return create(macroKey, "Embed IFrame", "Generic iframe embedder", form);
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class AbstractCommand method doTransformInlineMixins.
private ContentTypes doTransformInlineMixins(final ContentTypes contentTypes) {
final ContentTypes.Builder transformedContentTypes = ContentTypes.create();
for (final ContentType contentType : contentTypes) {
final Form transformedForm = mixinService.inlineFormItems(contentType.getForm());
final ContentType transformedCty = ContentType.create(contentType).form(transformedForm).build();
transformedContentTypes.add(transformedCty);
}
return transformedContentTypes.build();
}
Aggregations