Skip to content

Commit

Permalink
MDL-78288 formslib: Document new filter_shown_headers function in For…
Browse files Browse the repository at this point in the history
…ms API
  • Loading branch information
aanabit authored Jul 11, 2023
1 parent 3f69582 commit 402ca94
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/apis/subsystems/form/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,30 @@ public function definition() {
}
```

### filter_shown_headers()

import { Since } from '@site/src/components';

<Since version="4.3" />

This method adds values to _shownonlyelements array to decide whether a header should be shown or hidden.

```php
public function filter_shown_headers(array $shownonly): void {
$this->_shownonlyelements = [];
if (empty($shownonly)) {
return;
}
foreach ($shownonly as $headername) {
$element = $this->getElement($headername);
if ($element->getType() == 'header') {
$this->_shownonlyelements[] = $headername;
$this->setExpanded($headername);
}
}
}
```

### Other features

In some cases you may want to [group elements](https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#Use_Fieldsets_to_group_Form_Elements) into collections.
Expand Down

0 comments on commit 402ca94

Please sign in to comment.