4 * Allows custom data specific to HTMLFormField to be set for OOjs UI forms. A matching JS widget
5 * (defined in htmlform.Element.js) picks up the extra config when constructed using OO.ui.infuse().
7 * Currently only supports passing 'hide-if' data.
9 trait HTMLFormElement
{
11 protected $hideIf = null;
13 public function initializeHTMLFormElement( array $config = [] ) {
15 $this->hideIf
= isset( $config['hideIf'] ) ?
$config['hideIf'] : null;
18 if ( $this->hideIf
) {
19 $this->addClasses( [ 'mw-htmlform-hide-if' ] );
21 $this->registerConfigCallback( function( &$config ) {
22 if ( $this->hideIf
!== null ) {
23 $config['hideIf'] = $this->hideIf
;
29 class HTMLFormFieldLayout
extends OOUI\FieldLayout
{
32 public function __construct( $fieldWidget, array $config = [] ) {
34 parent
::__construct( $fieldWidget, $config );
36 $this->initializeHTMLFormElement( $config );
39 protected function getJavaScriptClassName() {
40 return 'mw.htmlform.FieldLayout';
44 class HTMLFormActionFieldLayout
extends OOUI\ActionFieldLayout
{
47 public function __construct( $fieldWidget, $buttonWidget = false, array $config = [] ) {
49 parent
::__construct( $fieldWidget, $buttonWidget, $config );
51 $this->initializeHTMLFormElement( $config );
54 protected function getJavaScriptClassName() {
55 return 'mw.htmlform.ActionFieldLayout';