X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLForm.php;h=f2c2aab3710098b9c0ea61d9700da6aa265e6fdd;hb=5eda39e04ba76d73885fa1d7554e5e8d5622e47a;hp=ce14003836d025bcab2b553659eef6b6b6318259;hpb=bfba8d87cde54b0fb59cdab0ce41309ac625d296;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index ce14003836..f2c2aab371 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -51,6 +51,7 @@ * 'id' -- HTML id attribute * 'cssclass' -- CSS class * 'csshelpclass' -- CSS class used to style help text + * 'dir' -- Direction of the element. * 'options' -- associative array mapping labels to values. * Some field types support multi-level arrays. * 'options-messages' -- associative array mapping message keys to values. @@ -83,6 +84,27 @@ * is "wp{$fieldname}". If you want a different name * (eg one without the "wp" prefix), specify it here and * it will be used without modification. + * 'hide-if' -- expression given as an array stating when the field + * should be hidden. The first array value has to be the + * expression's logic operator. Supported expressions: + * 'NOT' + * [ 'NOT', array $expression ] + * To hide a field if a given expression is not true. + * '===' + * [ '===', string $fieldName, string $value ] + * To hide a field if another field identified by + * $field has the value $value. + * '!==' + * [ '!==', string $fieldName, string $value ] + * Same as [ 'NOT', [ '===', $fieldName, $value ] + * 'OR', 'AND', 'NOR', 'NAND' + * [ 'XXX', array $expression1, ..., array $expressionN ] + * To hide a field if one or more (OR), all (AND), + * neither (NOR) or not all (NAND) given expressions + * are evaluated as true. + * The expressions will be given to a JavaScript frontend + * module which will continually update the field's + * visibility. * * Since 1.20, you can chain mutators to ease the form generation: * @par Example: @@ -216,6 +238,7 @@ class HTMLForm extends ContextSource { */ protected $availableSubclassDisplayFormats = array( 'vform', + 'ooui', ); /** @@ -234,6 +257,9 @@ class HTMLForm extends ContextSource { case 'vform': $reflector = new ReflectionClass( 'VFormHTMLForm' ); return $reflector->newInstanceArgs( $arguments ); + case 'ooui': + $reflector = new ReflectionClass( 'OOUIHTMLForm' ); + return $reflector->newInstanceArgs( $arguments ); default: $reflector = new ReflectionClass( 'HTMLForm' ); $form = $reflector->newInstanceArgs( $arguments ); @@ -1370,6 +1396,17 @@ class HTMLForm extends ContextSource { Html::rawElement( 'tbody', array(), "\n$html\n" ) ) . "\n"; } elseif ( $displayFormat === 'inline' ) { $html = Html::rawElement( 'span', $attribs, "\n$html\n" ); + } elseif ( $displayFormat === 'ooui' ) { + $config = array( + 'classes' => $classes, + ); + if ( $sectionName ) { + $config['id'] = Sanitizer::escapeId( $sectionName ); + } + $fieldset = new OOUI\FieldsetLayout( $config ); + // Ewww. We should pass this as $config['items'], but there might be string snippets. + $fieldset->group->appendContent( new OOUI\HtmlSnippet( $html ) ); + $html = $fieldset->toString(); } else { $html = Html::rawElement( 'div', $attribs, "\n$html\n" ); }