Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 and 403]

Form fields helper.

Copyright: 2013 David MonllaĆ³
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 359 lines (13 kb)
Included or required: 5 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: behat_field_manager  - X-Ref

Helper to interact with form fields.

get_form_field_from_label($label, RawMinkContext $context)   X-Ref
Gets an instance of the form field from it's label

param: string $label
param: RawMinkContext $context
return: behat_form_field

get_form_field(NodeElement $fieldnode, Session $session)   X-Ref
Gets an instance of the form field.

Not all the fields are part of a moodle form, in this
cases it fallsback to the generic form field. Also note
that this generic field type is using a generic setValue()
method from the Behat API, which is not always good to set
the value of form elements.

param: NodeElement $fieldnode
param: Session $session The behat browser session
return: behat_form_field

get_field_instance($type, NodeElement $fieldnode, Session $session)   X-Ref
Returns the appropiate behat_form_field according to the provided type.

It defaults to behat_form_field.

param: string $type The field type (checkbox, date_selector, text...)
param: NodeElement $fieldnode
param: Session $session The behat session
return: behat_form_field

guess_field_type(NodeElement $fieldnode, Session $session)   X-Ref
Guesses a basic field type and returns it.

This method is intended to detect HTML form fields when no
moodleform-specific elements have been detected.

param: NodeElement $fieldnode
param: Session $session
return: string|bool The field type or false.

is_moodleform_field(NodeElement $fieldnode)   X-Ref
Detects when the field is a moodleform field type.

Note that there are fields inside moodleforms that are not
moodleform element; this method can not detect this, this will
be managed by get_field_node_type, after failing to find the form
element element type.

param: NodeElement $fieldnode
return: bool

get_dom_elements_for_node(NodeElement $fieldnode, Session $session)   X-Ref
Get the DOMDocument and DOMElement for a NodeElement.

param: NodeElement $fieldnode
param: Session $session
return: array

get_field_node_type(NodeElement $fieldnode, Session $session)   X-Ref
Recursive method to find the field type.

Depending on the field the felement class node is in a level or in another. We
look recursively for a parent node with a 'felement' class to find the field type.

param: NodeElement $fieldnode The current node.
param: Session $session The behat browser session
return: null|string A text description of the node type, or null if one could not be accurately determined

get_field_type(\DOMDocument $document, \DOMElement $node, Session $session)   X-Ref
Get the field type from the specified DOMElement.

param: \DOMDocument $document
param: \DOMElement $node
param: Session $session
return: null|string

normalise_fieldtype(string $fieldtype)   X-Ref
Normalise the field type.

param: string $fieldtype
return: string

get_field()   X-Ref


get_node_type()   X-Ref