OOUI
Object-Oriented User Interface
Loading...
Searching...
No Matches
OOUI\FieldLayout Class Reference

Layout made of a field and optional label. More...

+ Inheritance diagram for OOUI\FieldLayout:
+ Collaboration diagram for OOUI\FieldLayout:

Public Member Functions

 __construct ( $fieldWidget, array $config=[])
 
 getField ()
 Get the field.
 
 isFieldInline ()
 Return true if the given field widget can be used with ‘'inline’alignment (see setAlignment()).
 
 getConfig (&$config)
 @inheritDoc
 
- Public Member Functions inherited from OOUI\Layout
 __construct (array $config=[])
 
- Public Member Functions inherited from OOUI\Element
 getTagName ()
 Get the HTML tag name.
 
 toggle ( $show=null)
 Toggle visibility of an element.
 
 getData ()
 Get element data.
 
 setData ( $data)
 Set element data.
 
 supports ( $methods)
 Check if element supports one or more methods.
 
 registerConfigCallback (callable $func)
 Register an additional function to call when building the config.
 
 toString ()
 Render element into HTML.
 
- Public Member Functions inherited from OOUI\Tag
 __construct ( $tag='div')
 Create element.
 
 hasClass ( $class)
 Check for CSS class.
 
 addClasses (array $classes)
 Add CSS classes.
 
 removeClasses (array $classes)
 Remove CSS classes.
 
 toggleClasses (array $classes, $toggle=null)
 Toggle CSS classes.
 
 getTag ()
 
 getAttribute ( $key)
 Get HTML attribute value.
 
 setAttributes (array $attributes)
 Add HTML attributes.
 
 setValue ( $value)
 Set value of input element ('value' attribute for most, element content for textarea).
 
 removeAttributes (array $keys)
 Remove HTML attributes.
 
 removeContent (... $content)
 Remove any items that match by reference.
 
 appendContent (... $content)
 Add content to the end.
 
 prependContent (... $content)
 Add content to the beginning.
 
 clearContent ()
 Remove all content.
 
 getElementGroup ()
 Get group element is in.
 
 setElementGroup ( $group)
 Set group element is in.
 
 setInfusable ( $infusable)
 Enable widget for client-side infusion.
 
 isInfusable ()
 Get client-side infusability.
 
 ensureInfusableId ()
 Ensure that this given Tag is infusable and has a unique id attribute.
 
 __toString ()
 Magic method implementation.
 

Protected Member Functions

 setAlignment ( $value)
 Set the field alignment mode.
 
 formatTitleWithAccessKey ( $title)
 Include information about the widget's accessKey in our title.
 
- Protected Member Functions inherited from OOUI\Element
 getJavaScriptClassName ()
 The class name of the JavaScript version of this widget.
 
 getGeneratedAttributes ()
 

Protected Attributes

string $align
 Alignment.
 
Widget $fieldWidget
 Field widget to be laid out.
 
array $errors
 Error messages.
 
array $warnings
 Warning messages.
 
array $successMessages
 Success messages.
 
array $notices
 Notice messages.
 
ButtonWidget string $help
 
Tag $field
 
Tag $header
 
Tag $body
 
Tag $messages
 
string $helpText
 
string false $helpInline
 
- Protected Attributes inherited from OOUI\Element
mixed $data = null
 Element data.
 
bool $visible = true
 
array $ownClasses = []
 Strings of the CSS classes explicitly configured for this element (as opposed to #$classes, which contains all classes for this element).
 
callable[] $configCallbacks = []
 
- Protected Attributes inherited from OOUI\Tag
string $tag = ''
 Tag name for this instance.
 
array $attributes = []
 Attributes.
 
array $classes = []
 Classes.
 
array $content = []
 Content.
 
GroupElement null $elementGroup = null
 Group.
 
bool $infusable = false
 Infusion support.
 

Additional Inherited Members

- Static Public Member Functions inherited from OOUI\Element
static warnDeprecation ( $message='')
 Emits a deprecation warning with provided message.
 
static getDir (Tag $element)
 Get the direction of the user interface for a given element.
 
static setDefaultDir ( $dir)
 Set the default direction of the user interface.
 
static configFromHtmlAttributes (array $attrs)
 A helper method to massage an array of HTML attributes into a format that is more likely to work with an OOUI PHP element, camel-casing attribute names and setting values of boolean ones to true.
 
- Static Public Member Functions inherited from OOUI\Tag
static generateElementId ()
 Generate a unique ID for element.
 
static resetElementId ()
 Reset the unique ID, for consistent test output.
 
static isSafeUrl ( $url)
 Check whether user-supplied URL is safe, that is, whether outputting it will not result in XSS vulnerability.
 
- Static Public Attributes inherited from OOUI\Element
static string $tagName = 'div'
 HTML tag name.
 
static string $defaultDir = 'ltr'
 Default text direction, used for some layout calculations.
 

Detailed Description

Layout made of a field and optional label.

Available label alignment modes include:

  • left: Label is before the field and aligned away from it, best for when the user will be scanning for a specific label in a form with many fields
  • right: Label is before the field and aligned toward it, best for forms the user is very familiar with and will tab through field checking quickly to verify which field they are in
  • top: Label is before the field and above it, best for when the user will need to fill out all fields from top to bottom in a form with few fields
  • inline: Label is after the field and aligned toward it, best for small boolean fields like checkboxes or radio buttons

Constructor & Destructor Documentation

◆ __construct()

OOUI\FieldLayout::__construct ( $fieldWidget,
array $config = [] )
Parameters
Widget$fieldWidgetField widget. An exception is thrown if no widget is specified.
array$configConfiguration options
  • string $config['align'] Alignment mode, either 'left', 'right', 'top' or 'inline' (default: 'left')
  • string[]|HtmlSnippet[] $config['errors'] Error messages about the widget.
  • string[]|HtmlSnippet[] $config['warnings'] Warning messages about the widget.
  • string[]|HtmlSnippet[] $config['notices'] Notices about the widget.
  • string|HtmlSnippet $config['help'] Explanatory text shown as a '?' icon, or inline.
  • bool $config['helpInline'] Whether or not the help should be inline, or shown when the "help" icon is clicked. (default: false)

Member Function Documentation

◆ formatTitleWithAccessKey()

OOUI\FieldLayout::formatTitleWithAccessKey ( $title)
protected

Include information about the widget's accessKey in our title.

TitledElement calls this method. (This is a bit of a hack.)

Parameters
string$titleTooltip label for 'title' attribute
Returns
string

◆ getConfig()

OOUI\FieldLayout::getConfig ( & $config)

@inheritDoc

Reimplemented from OOUI\Element.

Reimplemented in OOUI\ActionFieldLayout.

◆ getField()

OOUI\FieldLayout::getField ( )

Get the field.

Returns
Widget Field widget

◆ isFieldInline()

OOUI\FieldLayout::isFieldInline ( )

Return true if the given field widget can be used with ‘'inline’alignment (see setAlignment()).

Returnfalse` if it can't or if this can't be determined.

Returns
bool

◆ setAlignment()

OOUI\FieldLayout::setAlignment ( $value)
protected

Set the field alignment mode.

Parameters
string$valueAlignment mode, either 'left', 'right', 'top' or 'inline'
Returns
$this

The documentation for this class was generated from the following file: