Search in sources :

Example 41 with Form

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

the class XmlMixinParser method doParse.

@Override
protected void doParse(final DomElement root) throws Exception {
    assertTagName(root, "mixin");
    this.builder.displayName(root.getChildValueTrimmed("display-name"));
    this.builder.displayNameI18nKey(root.getChild("display-name") != null ? root.getChild("display-name").getAttribute("i18n") : null);
    this.builder.description(root.getChildValue("description"));
    this.builder.descriptionI18nKey(root.getChild("description") != null ? root.getChild("description").getAttribute("i18n") : null);
    final XmlFormMapper mapper = new XmlFormMapper(this.currentApplication);
    final Form form = mapper.buildForm(root.getChild("form"));
    this.builder.form(form);
}
Also used : Form(com.enonic.xp.form.Form)

Example 42 with Form

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

the class IndexConfigVisitorTest method htmlArea_in_itemSet.

@Test
public void htmlArea_in_itemSet() throws Exception {
    FormItemSet myFormItemSet = FormItemSet.create().name("myFormItemSet").label("My form item set").addFormItem(Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(false).build()).build();
    Form form = Form.create().addFormItem(myFormItemSet).build();
    final PatternIndexConfigDocument.Builder builder = PatternIndexConfigDocument.create();
    final IndexConfigVisitor validationVisitor = new IndexConfigVisitor("parent", builder);
    validationVisitor.traverse(form);
    final PatternIndexConfigDocument document = builder.build();
    assertEquals(1, document.getPathIndexConfigs().size());
    assertEquals("htmlStripper", document.getConfigForPath(PropertyPath.from("parent.myFormItemSet.htmlArea")).getIndexValueProcessors().get(0).getName());
}
Also used : Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) FormItemSet(com.enonic.xp.form.FormItemSet) Test(org.junit.jupiter.api.Test)

Example 43 with Form

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

the class SiteConfigProcessorTest method test_site_config_with_html_area.

@Test
public void test_site_config_with_html_area() throws Exception {
    final Form form = Form.create().addFormItem(Input.create().name("text1").label("text1").inputType(InputTypeName.HTML_AREA).build()).build();
    final SiteConfigs siteConfigs = SiteConfigs.create().add(SiteConfig.create().application(applicationKey1).config(new PropertyTree()).build()).build();
    final PatternIndexConfigDocument result = processConfigs(siteConfigs, form);
    assertEquals(1, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(ContentPropertyNames.DATA, SITECONFIG, "config", "text1")).getIndexValueProcessors().get(0).getName());
}
Also used : Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) SiteConfigs(com.enonic.xp.site.SiteConfigs) Test(org.junit.jupiter.api.Test)

Example 44 with Form

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

the class SiteConfigProcessorTest method test_multiple_site_configs_with_same_path.

@Test
public void test_multiple_site_configs_with_same_path() throws Exception {
    final Form form1 = Form.create().addFormItem(Input.create().name("text1").label("text1").inputType(InputTypeName.HTML_AREA).build()).build();
    final Form form2 = Form.create().addFormItem(Input.create().name("text1").label("text1").inputType(InputTypeName.HTML_AREA).build()).build();
    final SiteConfigs siteConfigs = SiteConfigs.create().add(SiteConfig.create().application(applicationKey1).config(new PropertyTree()).build()).add(SiteConfig.create().application(applicationKey2).config(new PropertyTree()).build()).build();
    final PatternIndexConfigDocument result = processConfigs(siteConfigs, form1, form2);
    assertEquals(1, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(ContentPropertyNames.DATA, SITECONFIG, "config", "text1")).getIndexValueProcessors().get(0).getName());
}
Also used : Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) SiteConfigs(com.enonic.xp.site.SiteConfigs) Test(org.junit.jupiter.api.Test)

Example 45 with Form

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

the class SiteConfigProcessorTest method test_multiple_site_configs_with_html_areas.

@Test
public void test_multiple_site_configs_with_html_areas() throws Exception {
    final Form form1 = Form.create().addFormItem(Input.create().name("text1").label("text1").inputType(InputTypeName.HTML_AREA).build()).build();
    final Form form2 = Form.create().addFormItem(Input.create().name("text2").label("text2").inputType(InputTypeName.HTML_AREA).build()).build();
    final SiteConfigs siteConfigs = SiteConfigs.create().add(SiteConfig.create().application(applicationKey1).config(new PropertyTree()).build()).add(SiteConfig.create().application(applicationKey2).config(new PropertyTree()).build()).build();
    final PatternIndexConfigDocument result = processConfigs(siteConfigs, form1, form2);
    assertEquals(2, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(ContentPropertyNames.DATA, SITECONFIG, "config", "text1")).getIndexValueProcessors().get(0).getName());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(ContentPropertyNames.DATA, SITECONFIG, "config", "text2")).getIndexValueProcessors().get(0).getName());
}
Also used : Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) SiteConfigs(com.enonic.xp.site.SiteConfigs) Test(org.junit.jupiter.api.Test)

Aggregations

Form (com.enonic.xp.form.Form)79 Test (org.junit.jupiter.api.Test)59 PropertyTree (com.enonic.xp.data.PropertyTree)36 FormDefaultValuesProcessor (com.enonic.xp.form.FormDefaultValuesProcessor)17 Input (com.enonic.xp.form.Input)17 FormItemSet (com.enonic.xp.form.FormItemSet)13 FormOptionSet (com.enonic.xp.form.FormOptionSet)11 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)10 ContentType (com.enonic.xp.schema.content.ContentType)8 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)7 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)5 PropertySet (com.enonic.xp.data.PropertySet)5 Content (com.enonic.xp.content.Content)4 CreateContentParams (com.enonic.xp.content.CreateContentParams)4 EditableContent (com.enonic.xp.content.EditableContent)4 MacroKey (com.enonic.xp.macro.MacroKey)4 XData (com.enonic.xp.schema.xdata.XData)4 SiteConfigs (com.enonic.xp.site.SiteConfigs)4 ContentPath (com.enonic.xp.content.ContentPath)3 Page (com.enonic.xp.page.Page)3