Skip to content

Latest commit

 

History

History
71 lines (56 loc) · 1.48 KB

options.md

File metadata and controls

71 lines (56 loc) · 1.48 KB

HAPEL Method Parameters


$options

(array), (optional), default: null

Provides an array of values to be used in the element's <option> tags.

NOTE: Some methods use both the array's keys and values while others use only the values. For example datalist() uses only the values while select() uses both the values and keys as seen below.

Value Use
array the values to create options

Examples:

Values Only

This demonstrates a method that requires only values.

$options = [
    'Foo',
    'Bar',
    'Baz'
];
<option value="foo"/>
<option value="bar"/>
<option value="baz"/>

Key / Value Pairs

This demonstrates a method that requires a key/value pair.

$options = [
    'foo'  =>  'Foo',
    'bar'  =>  'Bar',
    'baz'  =>  'Baz'
];
<option value="foo">Foo</option>
<option value="bar">Bar</option>
<option value="baz">Baz</option>

Values Only Used On Key/Value Pair Methods

This demonstrates a method that requires a key/value pair in which only values are passed. Note the values of the <option> tags are the key's numeric value. There may be times when output like this is desirable, however, most times this is not intended.

$options = [
    'Foo',
    'Bar',
    'Baz'
];
<option value="0">Foo</option>
<option value="1">Bar</option>
<option value="2">Baz</option>