Mandatory/Optional content blocks relatively to context

It will be nice to have a functionality that will allow to change state of fields(optional or mandatory) regarding to other fields. For example on some typical page I have a placeholder for a block that could exist in two(or more) views, and for one type of view I have one bunch of mandatory fields, and for other type of view I have completelly different bunch of mandatory fields. But, even since I need to configure only one block, I need to fill all parameters for both blocks.

Maybe chain such functionality with fieldsets?

Maybe you could use this from the upcoming 6.8 release:

  • New OptionSet form item type, allowing you to define many different combinations of inputs and allow user to choose which to use. (I.e. create one option per form field, and use multiple function to just add new options to the form)

Mentioned here: Form builder app

1 Like

Does optionSet solve this issue @dobrKot?
http://xp.readthedocs.io/en/latest/developer/schema/option-sets.html

1 Like

Hm, I have installed latest 6.7.3 version, and tried to use “option-set”. Looking on latest model.xsd I should put it inside formItems tag :

(Some restrictions on writing pure *.xml? Uploaded a picture of xml instead.)

And that is what I have done, just copy-pasted this example http://xp.readthedocs.io/en/latest/developer/schema/option-sets.html inside “formItems”. But than I have got an error in XmlFormMapper.java: com.enonic.xp.xml.XmlException: Unknown item type [option-set].

It seems to be that option-set - is fail option in 6.7.3:

private FormItem buildItem( final DomElement root )
{
    final String tagName = root.getTagName();
    if ( "input".equals( tagName ) )
    {
        return buildInputItem( root );
    }

    if ( "field-set".equals( tagName ) )
    {
        return buildFieldSetItem( root );
    }

    if ( "inline".equals( tagName ) )
    {
        return buildInlineItem( root );
    }

    if ( "item-set".equals( tagName ) )
    {
        return buildFormItemSetItem( root );
    }

    throw new XmlException( "Unknown item type [{0}]", tagName );
}

Hi dobrKot

Option-set that Thomas is talking about is a 6.8-feature. So you need to try our Beta2 (or Beta1) of XP 6.8. You can find it here:
http://repo.enonic.com/public/com/enonic/xp/distro/6.8.0-B2/

Ok, than it’s not really obvious what is currently the very last version of app. Because on this page I was offered to download 6.7.3 version https://enonic.com/downloads#download-other, and on this page http://xp.readthedocs.io/en/latest/developer/schema/option-sets.html there is no info on which version it’s working.

I will try to check out this new feature as soon as possible on 6.8, but it’s look like what I need.

The “latest”-version in the docs always refer to the latest (even un-released) version, like for 6.8.0-B2. You can switch version on the bottom of the menu-column to use docs for older versions.

The download-page, however, will always use the latest release version, which is currently 6.7.3. (6.8.0 will have to come out of beta before it is released) The beta is available from http://repo.enonic.com/public/com/enonic/xp/distro/.

2 Likes