Usage

A basic example of a form input being generated follows. Here we are instantiating the form elements class then adding an input with the name my_input_name . We’re also using a ternary operator to pass a value to the input.

select-icons

Adds a Layers UI icon or custom image to your option, (for an example, see the customizer under Header → Layout.) Each option value is added as a class to the icon, prefixed with icon-, allowing you to add an icon font to each option. This is like a select menu or checkbox, where the user chooses an option by pressing the icon or image.

In the following case, each select icon in the control will have the class icon-full-width and icon-boxed . An example of how you might add custom select icons is in adding layout controls to your child theme for a custom page template.

Added in 1.2.12, the link-group input field will pull in the dynamic linking function for allowing custom or post/page search and new tab toggling. This field should replace any previous use of the button field type.

The following example demonstrates how to convert a widget button link and text fields to the new link group.

PHP

1

2

3

4

5

6

7

8

echo$this->form_elements()->input(

array(

'type'=>'link-group',

'name'=>$this->get_layers_field_name('button'),

'id'=>$this->get_layers_field_id('button'),

'value'=>(isset($widget['button']))?$widget['button']:NULL,

)

);

trbl-fields

Adds a group of fields with the intention of using them in CSS. trbl refers to Top / Right / Bottom / Left. We use this input in our margin and padding controls in the Advanced section of the design bar. This type is available to widgets only.

PHP

1

2

3

4

5

6

echo$form_elements->input(array(

'type'=>'trbl-fields',

'name'=>'my_trbl_name',

'id'=>'my-trbl-id'

'value'=>(isset($trbl)?$trbl:'')

));

Wrappers & Labels

Each input can be wrapped in a layers-form-item and given a label, if the input type does not use a label argument.

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

14

// Text Field

echo'<p class="layers-form-item">';

echo'<label>'.__('Text Field','layerswp').'</label> ';

echo$form_elements->input(

array(

'type'=>'text',

'name'=>'my_text_field',

'id'=>'my_text_field',

'placeholder'=>__('Enter some text...','layerswp'),

'value'=>(isset($my_text_field)?$my_text_field:''),

'class'=>'layers-text'

)

);

echo'</p>';

Line 2: (optional) Set your field wrapper. Using a paragraph tag with the layers-form-item class will render your field full width like the Video URL field. If you do not use a wrapper, the fields will simply sit next to one another: