Commit 12abe6a6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Refactor to new class Checkbox() finished.

parent a8085f6d
Pipeline #2875 failed with stages
in 1 minute and 56 seconds
......@@ -807,7 +807,7 @@ EOF;
// Label
if ($formElement[FE_BS_LABEL_COLUMNS] != '0') {
$htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
$htmlLabel = HelperFormElement::buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
}
$html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS],
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ class HelperFormElement {
/**
* @var Store
*/
protected $store = null;
private static $store = null;
/**
* Expand column $keyName to row array as virtual columns.
......@@ -790,4 +790,74 @@ EOF;
return $attribute;
}
/**
* Builds a real HTML hidden form element. Useful for checkboxes, Multiple-Select and Radios.
*
* @param $htmlFormElementName
* @param string $value
*
* @return string
*/
public static function buildNativeHidden($htmlFormElementName, $value) {
return '<input type="hidden" name="' . $htmlFormElementName . '" value="' . htmlentities($value) . '">';
}
/**
* Set corresponding JSON attributes readonly/required/disabled, based on $formElement[FE_MODE].
*
* @param string $feMode
*
* @return array
* @throws \UserFormException
*/
public static function getJsonFeMode($feMode) {
self::getFeMode($feMode, $dummy, $disabled, $required);
return [API_FORM_UPDATE_DISABLED => ($disabled === 'yes'), API_FORM_UPDATE_REQUIRED => ($required === 'yes')];
}
/**
* Builds a label, typically for an html-'<input>'-element.
*
* @param string $htmlFormElementName
* @param string $label
* @param string $addClass
*
* @return string
* @throws \CodeException
*/
public static function buildLabel($htmlFormElementName, $label, $addClass = '') {
$attributes = Support::doAttribute('for', $htmlFormElementName);
$attributes .= Support::doAttribute('class', ['control-label', $addClass]);
$html = Support::wrapTag("<label $attributes>", $label);
return $html;
}
/**
* Construct HTML ID for checkbox/radio option elements.
* Optional add $type.
* Example: $base='173-21612-1-0', $index='0', $type='l' >> '173-21612-1-0-0-l'
*
* @param $base
* @param $index
* @param string $type - ';' for label
* @return string
*/
public static function getCheckboxRadioOptionId($base, $index, $type = '') {
return $base . '-' . $index . $type;
}
/**
* Build HelpBlock
*
* @return string
*/
public static function getHelpBlock() {
return '<div class="help-block with-errors hidden"></div>';
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment