PHP code example of signify-nz / silverstripe-dependentrequiredfields

1. Go to this page and download the library: Download signify-nz/silverstripe-dependentrequiredfields library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

signify-nz / silverstripe-dependentrequiredfields example snippets



    public function getCMSValidator() {
        return DependentRequiredFields::create([
            'AlwaysRequiredField',
            'ExactValueField' => ['DependencyField' => 'someExactValue'],
            'StartsWithField' => ['DependencyField:StartsWith' => 'some'],
        ]);
    }

$validator->addDependentRequiredField('GreaterThanField', ['DependencyField:GreaterThan' => '10']);
$validator->removeDependentRequiredField('ExactValueField');