madeyourday/contao-rocksolid-custom-elements

depends On inherit to List element

Closed this issue · 2 comments

Hello,
I want to modify a 'inputType' => 'list' depending on a selection above But it is not working.

'mapMode' => array(
    'label' => array('Kartenmodus', 'Wählen Sie den Modus für die Karte aus.'),
    'inputType' => 'select',
    'options' => array('default' => 'Normal', 'advanced' => 'Erweiterter Modus'),
    'eval' => array('tl_class' => 'w50')
),

'boxes' => array(
    'label' => array('Objekte', 'Verwalten Sie die Objekte auf der Karte'),
    'elementLabel' => '%s. Objekt',
    'inputType' => 'list',
    'minItems' => 1,
    'fields' => array(
        'name' => array(
            'label' => array('Name', 'Geben Sie den Namen des Objekts ein'),
            'inputType' => 'text',
            'eval' => array('mandatory' => false, 'tl_class' => 'w50 clr'),
            'eval' => array('mandatory' => false, 'tl_class' => 'w50 clr'),
            'dependsOn' => array(
                'field' => 'mapMode',
                'value' => 'advanced',
            ),
        ),
    )

Is "dependsOn" only working in the "same" Level?

Greets

ausi commented

You can reference a field one level up by using:

'dependsOn' => array(
    'field' => '../mapMode',
    'value' => 'advanced',
),

You can reference a field one level up by using:

'dependsOn' => array(
    'field' => '../mapMode',
    'value' => 'advanced',
),

Perfect! thy for you help. Maybe you should add this to the documentation...