Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sheadawson committed Sep 13, 2014
1 parent f19ff3e commit 8690cae
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ SilverStripe 3
##Usage example

```php
// 1. Create a callable function that returns an array of options for the DependentDropdownField. When the value of the field it depends on changes, this function is called passing the updated value as the first parameter ($val)
// 1. Create a callable function that returns an array of options for the DependentDropdownField.
// When the value of the field it depends on changes, this function is called passing the
// updated value as the first parameter ($val)
$datesSource = function($val){
if($val == 'one'){
// return appropriate options array if the value is one.
Expand All @@ -22,7 +24,8 @@ $datesSource = function($val){
$fields = FieldList::create(
// 2. Add your first field to your field list,
$fieldOne = DropdownField::create('FieldOne','Field One', array('one' => 'One', 'two' => 'Two'),
// 3. Add your DependentDropdownField, setting the source as the callable function you created and setting the field it depends on to the appropriate field
// 3. Add your DependentDropdownField, setting the source as the callable function
// you created and setting the field it depends on to the appropriate field
DependentDropdownField::create('FieldTwo','Field Two', $datesSource)->setDepends($fieldOne)
);
```

0 comments on commit 8690cae

Please sign in to comment.