public |
#
__construct( $parameters, $parent_form )
Constructs the element, parses the $parameters array and sets the element's properties
If in context element is tied to a form, pass as $parent_form .
See {@see set()} for details on 'core' parameters.
|
public |
#
get_parameters( )
|
public |
#
get_type( )
Returns the type of the booking form element.
Default types include:
input
select
radio
date ,
terms_conditions ...
|
public |
#
set( $param, $value )
Sets a parameter of the element
What attributes are used will depending on the implementing classes,
but some core attributes include:
id - The elements ID (unique to the booking form)
required - Whether the user must enter a value for this element
class - HTML class to add to the element
options - An array of possible options (e.g. in select /radio /checkbox fields)
selected - The selected value (e.g. in select /radio /checkbox fields)
value - The user-entered value ({@see set_value()});
|
public |
#
get( $param )
Returns the specified parameter
|
public |
#
get_field_name( $component )
Returns the HTML name attribute for this element.
Some elements might have multiple fields (e.g. address element).
The $component can be used to return the field name for a
specific field.
|
public |
#
set_value( $value, $component )
Sets the element's value as entered by the user.
If the booking form has associated user-entered data, this
sets the field's value to the given value. The $component
argument can be used if an element has multiple fields
|
public |
#
get_value( $component )
Returns the user-entered value associated with this element.
|
public |
#
is_required( )
Whether this form element is required.
|
public |
#
show_label( )
Whether a label should be displayed for this element
|
public |
#
get_parent( )
The parent of the element, if it's nested beneath another element.
If the element is 'top level', then this returns false /
|
public |
#
validate( $input )
Validate an entry for this form element.
TODO - don't pass $input, but instead use ::get_value()
Validates the recieved data $input is. The value for this particular element can be
found at $input[$this->id] . This shall be deprecated, use $this->get_value() instead.
$errors is a WP_Error object to add error messages to. These added to the form and displayed
as at the top of the form. To add an error to the field use ::set_errors();
|
public |
#
is_empty( )
|
public |
#
is_visible( $check_parent )
Checks if the element is visible as determined by it's conditional
'conditional' attribute is an array of the form:
- action - show/hide - what to do if conditions are met
- gate - all/any - whether all conditions, or only one condition needs to be met
- conditions - array of conditions. A condition is an array with keys 'target' (field ID)
to compare against given 'value', and 'operator' (=,!=,<,>,contains,!contains)
as the comparator.
|
public |
#
save( $booking_id )
|
public |
#
add_error( $code, $message, $data )
Adds an error to the element, codes should be unique.
The provided message is currently not used (but support is planned and
will appear next to the field).
To add an error the form (e.g display message at top,
use {@see EO_Booking_Form::add_error)}
|
public |
#
get_error_codes( )
Gets the error codes of the form's errors.
|
public |
#
get_error_message( $code )
Get the error message for the specified code.
This will get the first message available for the code. If no code is
given then the first code available will be used.
|
public |
#
has_errors( )
Returns true if any errors have been added to this element
|
public |
#
is_valid( $deprecated )
A method which should return true if the data provided for this element is 'valid'.
Data entered for this element can be retreived with
$this->get_value()
|
public |
#
get_defaults( )
Return an array of default parameters.
|
public |
#
accept( $visitor )
|
public |
#
get_class( )
Returns the CSS class of this element
This will be removed. Do not use.
|