Skip to content

Commit e752845

Browse files
committed
zem_contact_option handles label/value correctly
Fixes issue #47
1 parent cd55978 commit e752845

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

zem_contact_reborn.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,11 +1169,8 @@ function zem_contact_option($atts, $thing = null)
11691169
'value' => null,
11701170
), $atts));
11711171

1172-
$val = ($value !== null) ? $value : $thing;
1173-
1174-
if (empty($val)) {
1175-
$val = $label;
1176-
}
1172+
$val = ($value === null) ? (!empty($thing) ? $thing : (!empty($label) ? $label : null)) : $value;
1173+
$label = ($label === null) ? (!empty($thing) ? $thing : (!empty($value) ? $value : null)) : $label;
11771174

11781175
$attr = array();
11791176
$doctype = get_pref('doctype', 'xhtml');
@@ -1198,7 +1195,7 @@ function zem_contact_option($atts, $thing = null)
11981195

11991196
$classStr = (($class) ? ' class="' . $class . '"' : '');
12001197

1201-
return '<option' . $classStr . ($attr ? ' ' . implode(' ', $attr) : '') . '>' . txpspecialchars($val) . '</option>';
1198+
return '<option' . $classStr . ($attr ? ' ' . implode(' ', $attr) : '') . '>' . txpspecialchars($label) . '</option>';
12021199
}
12031200

12041201
/**
@@ -2380,10 +2377,12 @@ function zem_contact_if($atts, $thing = null)
23802377
h4. Attributes
23812378

23822379
* @class="space-separated values"@<br /> Set the CSS @class@ name of the option. Default: @zemOption@. To remove @class@ attribute from the element entirely, use @class=""@.
2383-
* @label="text"@ %(warning)required%<br />Text label of this option displayed to the user.
2380+
* @label="text"@<br />Text label of this option displayed to the user.
23842381
* @selected="boolean"@<br />Whether this item is selected, May also be specified in the container tag's @selected@ attribute. Available values: @1@ (yes) or @0@ (no).
23852382
* @value="text"@<br />The value associated with this option when submitted. Default is the label.
23862383

2384+
Without a @label@, it will take on the container or, failing that, the given @value@. Without a @value@, it will take on the container or, failing that, the given @label@.
2385+
23872386
h5. Example 1
23882387

23892388
bc(language-markup). <txp:zem_contact_select label="Department">

0 commit comments

Comments
 (0)