Form Fields API


wpbdp_get_form_fields( $args )

This function can be used to obtain form fields from the database based on several criteria. The returned objects are instances of WPBDP_FormField.

Parameters

  • $args: (optional) Array or querystring of arguments used to query fields from the database. The valid options here are:
    • association: Field association. Valid choices are “title”, “category”, “tags” and “meta”.
    • validators: Field validators. Prepending “-“ to the validator name excludes fields with that validator.
    • display_flags: Field display flags. Prepending “-“ to the display flag excludes fields with that display flag set.
    • unique: If TRUE only the first field will be returned.

Return

An array of WPBDP_FormField instances or just one object if the argument unique is set to TRUE.
Fields are ordered by their position (weight) inside the table. See WPBDP_FormField for more details.

Examples

Retrieve all fields (regardless of their nature) and print their label:

<?php
	$fields = wpbdp_get_form_fields();
	
	foreach ( $fields as $field ) {
		print $field->get_label();
	}
?>

Retrieve the one field with “title” association:

<?php
	$title_field = wpbdp_get_form_fields('association=title&unique=1');
?>

Retrieve all required fields that don’t appear in the search form:

<?php
	$args = array( 'validators' => 'required', 'display_flags' => '-search' );
	$fields = wpbdp_get_form_fields( $args );
?>

wpbdp_get_form_field( $id )

This function obtains a field by its ID. For more complex field-related queries, use wpbdp_get_form_fields.

Parameters

  • $id: the field ID

Return

A WPBDP_FormField instance if the field is found or NULL if not.

Class Reference: WPBDP_FormField

Properties

Most of the WPBDP_FormField properties are private and should not be accessed directly. Use the getters & setters for this.

Related Articles