[HTMLUtils] Add new attribute 'defaultValue'
Behavior depends on the type: - text: Allows any text - number: Allows any numeric - list: 'defaultValue' must match either name or value of one element - checkbox: 'defaultValue' must be checked to activate checkbox
This commit is contained in:
parent
3fd283e29f
commit
5d66af7a29
1 changed files with 13 additions and 4 deletions
|
@ -85,23 +85,32 @@ CARD;
|
|||
if(!isset($inputEntry['exampleValue']))
|
||||
$inputEntry['exampleValue'] = '';
|
||||
|
||||
if(!isset($inputEntry['defaultValue']))
|
||||
$inputEntry['defaultValue'] = '';
|
||||
|
||||
$idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($inputEntry['identifier']);
|
||||
$card .= '<label for="' . $idArg . '">' . $inputEntry['name'] . ' : </label>' . PHP_EOL;
|
||||
|
||||
if(!isset($inputEntry['type']) || $inputEntry['type'] == 'text') {
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="text" value="" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="text" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
|
||||
} else if($inputEntry['type'] == 'number') {
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="number" value="" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="number" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
|
||||
} else if($inputEntry['type'] == 'list') {
|
||||
$card .= '<select ' . $additionalInfoString . ' id="' . $idArg . '" name="' . $inputEntry['identifier'] . '" >';
|
||||
|
||||
foreach($inputEntry['values'] as $listValues) {
|
||||
$card .= '<option value="' . $listValues['value'] . '">' . $listValues['name'] . '</option>';
|
||||
if($inputEntry['defaultValue'] === $listValues['name'] || $inputEntry['defaultValue'] === $listValues['value'])
|
||||
$card .= '<option value="' . $listValues['value'] . '" selected>' . $listValues['name'] . '</option>';
|
||||
else
|
||||
$card .= '<option value="' . $listValues['value'] . '">' . $listValues['name'] . '</option>';
|
||||
}
|
||||
|
||||
$card .= '</select><br >';
|
||||
} else if($inputEntry['type'] == 'checkbox') {
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
|
||||
if($inputEntry['defaultValue'] === 'checked')
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . $inputEntry['identifier'] . '" checked /><br />' . PHP_EOL;
|
||||
else
|
||||
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="checkbox" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue