EDD_HTML_Elements
The EDD_HTML_Elements class provides a series of helper methods for rendering commonly used HTML fields with consistent markup, class names, and attributes.
The class includes methods for the following field types:
product_dropdown()
This method creates a
select html element with products in it. Values are product_ids and the text is Download titles.
Example:
echo EDD()->html->product_dropdown();
This would create a drop down list of products. The method takes one input, an array, and has these defaults:
$defaults = array( 'name' => 'products', 'id' => 'products', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'number' => 30, 'bundles' => true, 'placeholder' => sprintf( __( 'Select a %s', 'easy-digital-downloads' ), edd_get_label_singular() ) );
Here’s a description of what’s in each option:
name
This would be the html “name” property of the form element. Defaults to ‘products’.
Example:
id
This would be the html “id” property of the html element. Defaults to ‘products’.
Example:
class
This would be the “class” property of the html element. Defaults to nothing.
Example:
multiple
This makes the select menu be of the “multiple” type. Defaults to false.
Example:
selected
This allows you to provide the product_id of a Download and have that one be pre-selected when the form loads. Defaults to 0.
chosen
This activated the “chosen” jquery plugin on your select box. Defaults to false.
Examples both closed and open: