MediaWiki master
HTMLFormElement.php
Go to the documentation of this file.
1<?php
2
3// @phan-file-suppress PhanUndeclaredMethod
4
5namespace MediaWiki\HTMLForm;
6
16
18 protected $condState = null;
20 protected $modules = null;
21
22 public function initializeHTMLFormElement( array $config = [] ) {
23 // Properties
24 $this->condState = $config['condState'] ?? [];
25 $this->modules = $config['modules'] ?? [];
26
27 // Initialization
28 if ( $this->modules ) {
29 // JS code must be able to read this before infusing (before OOUI is even loaded),
30 // so we put this in a separate attribute (not with the rest of the config).
31 // And it's not needed anymore after infusing, so we don't put it in JS config at all.
32 $this->setAttributes( [ 'data-mw-modules' => implode( ',', $this->modules ) ] );
33 }
34 $this->registerConfigCallback( function ( &$config ) {
35 if ( $this->condState ) {
36 $config['condState'] = $this->condState;
37 }
38 } );
39 }
40}
41
43class_alias( HTMLFormElement::class, 'HTMLFormElement' );
initializeHTMLFormElement(array $config=[])
trait HTMLFormElement
Allows custom data specific to HTMLFormField to be set for OOUI forms.