cancel
Showing results for 
Search instead for 
Did you mean: 

How search with a form with more than one checkboxes?

gabriel_batista
Champ in-the-making
Champ in-the-making

I have an advanced search form with three checkboxes properties, when I check just one of this property the results are of documents that has only the checked property. Is possibly to make a form that can search for all documents with one checked property, but not excluding the documents with others unchecked properties?

Below a snippet of my code:

Custom model

<types>
    <type name="demo:demoPastaRH">
        <title>Tipo Pasta RH</title>
        <parent>cm:folder</parent>
        <mandatory-aspects>
            <aspect>demo:dadosFuncionario</aspect>
            <aspect>demo:validacaoConteudoPastaRH</aspect>
        </mandatory-aspects>
    </type>
</types>‍‍‍‍‍‍‍‍‍‍




<aspects>
    <aspect name="demo:dadosFuncionario">
        <properties>
            <property name="demo:cpfFuncionario">
                <type>d:text</type>
                <mandatory enforced="false">true</mandatory>
                <index enabled="true">
                    <atomic>true</atomic>
                    <stored>false</stored>
                    <tokenised>false</tokenised>
                </index>
            </property>
        </properties>
    </aspect>
   
    <aspect name="demo:validacaoConteudoPastaRH">
        <properties>
            <property name="demo:contemFRE">
                <type>d:boolean</type>
                <index enabled="true">
                    <atomic>true</atomic>
                    <stored>false</stored>
                    <tokenised>both</tokenised>
                </index>
            </property>
            <property name="demo:contemContratoTrabalho">
                <type>d:boolean</type>
                <index enabled="true">
                    <atomic>true</atomic>
                    <stored>false</stored>
                    <tokenised>both</tokenised>
                </index>
            </property>               
            <property name="demo:contemAsoAdmissional">
                <type>d:boolean</type>
                <index enabled="true">
                    <atomic>true</atomic>
                    <stored>false</stored>
                    <tokenised>both</tokenised>
                </index>
            </property>               
        </properties>
    </aspect>       
</aspects>

Search Form

<config evaluator="model-type" condition="demo:demoPastaRH">
    <forms>
        <!-- Search form -->
        <form id="search">
            <field-visibility>
                <show id="cm:name" />
                <show id="cm:description" />
                <show id="demo:cpfFuncionario" force="true" />
                <show id="demo:contemFRE" force="true" />
                <show id="demo:contemContratoTrabalho" force="true" />
                <show id="demo:contemAsoAdmissional" force="true" />
            </field-visibility>
            <appearance>
                <field id="demo:cpfFuncionario">
                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                </field>
                <field id="demo:contemFRE">
                    <control template="/org/alfresco/components/form/controls/checkbox.ftl" >
                        <control-param name="mode">OR</control-param>
                    </control>
                </field>              
                <field id="demo:contemContratoTrabalho">
                    <control template="/org/alfresco/components/form/controls/checkbox.ftl" >
                        <control-param name="mode">OR</control-param>
                    </control>
                </field>
                <field id="demo:contemAsoAdmissional">
                    <control template="/org/alfresco/components/form/controls/checkbox.ftl" >
                        <control-param name="mode">OR</control-param>
                    </control>
                </field>
            </appearance>               
        </form>
    </forms>
</config>
1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

For boolean fields I usually use a selectone control (instead of checkbox) and configure three options with "true", "false" and "" (empty string) as value.

View answer in original post

4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator

For boolean fields I usually use a selectone control (instead of checkbox) and configure three options with "true", "false" and "" (empty string) as value.

Hi Axel,

Thanks for your answer, I try your solution and the behavior is working as need. But the options "true", "false" and ""  are not that intuitive in my native language (Portuguese), there is a way to use other words in the droplist, like a key-value?

Those are just the values to be used in the backend. As you can see in the documentation for forms, a select list (selectone.ftl / selectmany.ftl) can contain localised display labels in its "options" parameter.

Thanks Axel, now the form is working as we would like.