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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations