Commit 71d80a99 authored by Carsten  Rose's avatar Carsten Rose
Browse files

FillStoreForm.php, AbstractBuilForm.php: rena,ed buildFormElementId() to...

FillStoreForm.php, AbstractBuilForm.php: rena,ed buildFormElementId() to buildFormElementName(), deleted: builddateJQW(), copied buildDateTime() to buildDateJQW - but not coded.
parent 19fdcb2a
......@@ -377,7 +377,7 @@ abstract class AbstractBuildForm {
// Typically: $htmlElementNameIdZero = true
// After Saving a record, staying on the form, the FormElements on the Client are still known as '<feName>:0'.
$htmlFormElementId = HelperFormElement::buildFormElementId($formElement['name'], ($htmlElementNameIdZero) ? 0 : $recordId);
$htmlFormElementId = HelperFormElement::buildFormElementName($formElement['name'], ($htmlElementNameIdZero) ? 0 : $recordId);
// Construct Marshaller Name: buildElement
$buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]];
......@@ -1740,7 +1740,7 @@ abstract class AbstractBuildForm {
/**
* Builds HTML 'input' element.
* Format: <input name="$htmlFormElementId" <type="email|input|password|url" [autocomplete="autocomplete"] [autofocus="autofocus"]
* Format: <input name="$htmlFormElementId" <type="date" [autocomplete="autocomplete"] [autofocus="autofocus"]
* [maxlength="$maxLength"] [placeholder="$placeholder"] [size="$size"] [min="$min"] [max="$max"]
* [pattern="$pattern"] [required="required"] [disabled="disabled"] value="$value">
*
......@@ -1750,33 +1750,74 @@ abstract class AbstractBuildForm {
* @param $value
* @param array $json
* @return string
* @throws \qfq\UserFormException
* @throws UserFormException
*/
public function builddateJQW(array $formElement, $htmlFormElementId, $value, array &$json) {
$textarea = '';
public function buildDateTime(array $formElement, $htmlFormElementId, $value, array &$json) {
$attribute = Support::doAttribute('name', $htmlFormElementId);
$attribute .= Support::doAttribute('class', 'form-control');
$htmlTag = '<input';
$arrMinMax = null;
$this->adjustMaxLength($formElement);
$showTime = ($formElement[FE_TYPE] == 'time' || $formElement[FE_TYPE] == 'datetime') ? 1 : 0;
$value = Support::convertDateTime($value, $formElement[FE_DATE_FORMAT], $formElement[FE_SHOW_ZERO], $showTime, $formElement[FE_SHOW_SECONDS]);
$tmpPattern = $formElement['checkPattern'];
$formElement['checkPattern'] = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement['dateFormat']);
// Get date format
if (!isset($formElement['dateFormat'])) {
$formElement['dateFormat'] = $this->store->getVar(SYSTEM_DATE_FORMAT, STORE_SYSTEM);
switch ($formElement['checkType']) {
case SANITIZE_ALLOW_PATTERN:
$formElement['checkPattern'] = $tmpPattern;
break;
case SANITIZE_ALLOW_MIN_MAX_DATE:
$arrMinMax = explode('|', $formElement['checkPattern'], 2);
if (count($arrMinMax) != 2) {
throw new UserFormException('Missing min|max definition', ERROR_MISSING_MIN_MAX);
}
break;
case SANITIZE_ALLOW_ALL:
case SANITIZE_ALLOW_ALNUMX:
case SANITIZE_ALLOW_ALLBUT:
$formElement['checkType'] = SANITIZE_ALLOW_PATTERN;
break;
default:
throw new UserFormException("Checktype not applicable for date/time: '" . $formElement['checkType'] . "'", ERROR_NOT_APPLICABLE);
}
// Format date
$value = Support::convertDateTime($value, $formElement[FE_DATE_FORMAT], $formElement[FE_SHOW_ZERO], 0, $formElement[FE_SHOW_SECONDS]);
// <input>
if ($formElement['maxLength'] > 0) {
// crop string only if it's not empty (substr returns false on empty strings)
if ($value !== '')
$value = substr($value, 0, $formElement['maxLength']);
// truncate if necessary
if ($value != '' && $formElement['maxLength'] > 0) {
$value = substr($value, 0, $formElement['maxLength']);
}
// 'maxLength' needs an upper 'L': naming convention for DB tables!
$attribute .= $this->getAttributeList($formElement, ['type', 'size', 'maxLength']);
$attribute .= Support::doAttribute('value', htmlentities($value), false);
$type = $formElement[FE_TYPE];
if ($type === 'datetime')
$type = 'datetime-local';
$attribute .= Support::doAttribute('type', $type);
// 'maxLength' needs an upper 'L': naming convention for DB tables!
$attribute .= $this->getAttributeList($formElement, ['size', 'maxLength']);
$attribute .= Support::doAttribute('value', htmlentities($value), false);
if ($formElement['placeholder'] == '') {
$timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm';
switch ($formElement[FE_TYPE]) {
case 'date':
$placeholder = $formElement['dateFormat'];
break;
case 'datetime':
$placeholder = $formElement['dateFormat'] . ' ' . $timePattern;
break;
case 'time':
$placeholder = $timePattern;
break;
default:
throw new UserFormException("Unexpected Formelement type: '" . $formElement[FE_TYPE] . "'", ERROR_FORMELEMENT_TYPE);
}
$formElement['placeholder'] = $placeholder;
}
$attribute .= $this->getAttributeList($formElement, ['autocomplete', 'autofocus', 'placeholder']);
......@@ -1784,11 +1825,16 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('title', $formElement['tooltip']);
$attribute .= $this->getInputCheckPattern($formElement['checkType'], $formElement['checkPattern']);
if (is_array($arrMinMax)) {
$attribute .= Support::doAttribute('min', $arrMinMax[0]);
$attribute .= Support::doAttribute('max', $arrMinMax[1]);
}
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE]);
$json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]);
return "$htmlTag $attribute>$textarea";
return "<input $attribute>" . $this->getHelpBlock();
}
......@@ -1806,7 +1852,7 @@ abstract class AbstractBuildForm {
* @return string
* @throws UserFormException
*/
public function buildDateTime(array $formElement, $htmlFormElementId, $value, array &$json) {
public function buildDateJQW(array $formElement, $htmlFormElementId, $value, array &$json) {
$attribute = Support::doAttribute('name', $htmlFormElementId);
$attribute .= Support::doAttribute('class', 'form-control');
......
......@@ -118,7 +118,7 @@ class FillStoreForm {
$formElement = $this->evaluate->parseArray($formElement, $debugStack);
// Get related formElement. Construct the field name used in the form.
$clientFieldName = HelperFormElement::buildFormElementId($formElement['name'], $sipValues[SIP_RECORD_ID]);
$clientFieldName = HelperFormElement::buildFormElementName($formElement['name'], $sipValues[SIP_RECORD_ID]);
// Some Defaults
$formElement = Support::setFeDefaults($formElement);
......
Supports Markdown
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