Commit e42eef41 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Index.rst: Describe attribute 'FormElement'.

AbstractBuildForm.php: Implement HTML Formelement attribute 'autofocus'. Add function checkAutoFocus().
parent 0768b92d
...@@ -322,6 +322,104 @@ abstract class AbstractBuildForm { ...@@ -322,6 +322,104 @@ abstract class AbstractBuildForm {
abstract public function getProcessFilter(); abstract public function getProcessFilter();
/**
* Check if there is an explicit 'autofocus' definition in at least one FE.
* Found: do nothing, it will be rendered at the correct position.
* Not found: set 'autofocus' on the first FE.
*
* Accepted misbehaviour on forms with pills: if there is at least one editable element on the first pill,
* the other pills are not checked - independent if there was a definition on the first pill or not.
* Reason: checks happens per pill - if there is no explizit definition on the first pill, take the first editable
* element of that pill.
*/
private function checkAutoFocus() {
static $found = false;
$idx = false;
if ($found) {
return;
}
// Search if there is an explicit autofocus definition.
for ($i = 0; $i < count($this->feSpecNative); ++$i) {
// Only check native elements which will be shown
if ($this->feSpecNative[$i][FE_CLASS] == FE_CLASS_NATIVE &&
($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW || $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED)
) {
// Check if there is an explicit definition.
if (isset($this->feSpecNative[$i][FE_AUTOFOCUS])) {
if ($this->feSpecNative[$i][FE_AUTOFOCUS] == '' || $this->feSpecNative[$i][FE_AUTOFOCUS] == '1') {
$this->feSpecNative[$i][FE_AUTOFOCUS] = '1'; // fix to '=1'
} else {
unset($this->feSpecNative[$i][FE_AUTOFOCUS]);
}
$found = true;
return;
}
if ($idx === false) {
$idx = $i;
}
}
}
// No explicit definition found: take the first found editable element.
if ($idx !== false) {
$found = true;
// No explicit definition found: set autofocus.
$this->feSpecNative[$idx][FE_AUTOFOCUS] = '1';
}
}
/**
* Check if there is an explicit 'autofocus' definition in at least one FE.
* Found: do nothing, it will be rendered at the correct position.
* Not found: set 'autofocus' on the first FE.
*
* Accepted misbehaviour on forms with pills: if there is at least one editable element on the first pill,
* the other pills are not checked - independent if there was a definition on the first pill or not.
* Reason: checks happens per pill - if there is no explizit definition on the first pill, take the first editable
* element of that pill.
*/
private function checkAutoFocus() {
static $found = false;
$idx = false;
if ($found) {
return;
}
// Search if there is an explicit autofocus definition.
for ($i = 0; $i < count($this->feSpecNative); ++$i) {
// Only check native elements which will be shown
if ($this->feSpecNative[$i][FE_CLASS] == FE_CLASS_NATIVE &&
($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW || $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED)
) {
// Check if there is an explicit definition.
if (isset($this->feSpecNative[$i][FE_AUTOFOCUS])) {
if ($this->feSpecNative[$i][FE_AUTOFOCUS] == '' || $this->feSpecNative[$i][FE_AUTOFOCUS] == '1') {
$this->feSpecNative[$i][FE_AUTOFOCUS] = '1'; // fix to '=1'
} else {
unset($this->feSpecNative[$i][FE_AUTOFOCUS]);
}
$found = true;
return;
}
if ($idx === false) {
$idx = $i;
}
}
}
// No explicit definition found: take the first found editable element.
if ($idx !== false) {
$found = true;
// No explicit definition found: set autofocus.
$this->feSpecNative[$idx][FE_AUTOFOCUS] = '1';
}
}
/** /**
* Process all FormElements: build corresponding HTML code. Collect and return all HTML code. * Process all FormElements: build corresponding HTML code. Collect and return all HTML code.
* *
...@@ -349,6 +447,9 @@ abstract class AbstractBuildForm { ...@@ -349,6 +447,9 @@ abstract class AbstractBuildForm {
$this->store->setVarArray($row, STORE_RECORD); $this->store->setVarArray($row, STORE_RECORD);
} }
$this->checkAutoFocus();
// Iterate over all FormElements // Iterate over all FormElements
foreach ($this->feSpecNative as $fe) { foreach ($this->feSpecNative as $fe) {
......
...@@ -461,6 +461,10 @@ const FE_MODE_READONLY = 'readonly'; ...@@ -461,6 +461,10 @@ const FE_MODE_READONLY = 'readonly';
const FE_MODE_REQUIRED = 'required'; const FE_MODE_REQUIRED = 'required';
const FE_MODE_HIDDEN = 'hidden'; const FE_MODE_HIDDEN = 'hidden';
const FE_CLASS_NATIVE = 'native';
const FE_CLASS_ACTION = 'action';
const FE_CLASS_CONTAINER = 'container';
const FE_SUBRECORD_ROW_CLASS = '_rowClass'; const FE_SUBRECORD_ROW_CLASS = '_rowClass';
const FE_SUBRECORD_ROW_TITLE = '_rowTitle'; const FE_SUBRECORD_ROW_TITLE = '_rowTitle';
...@@ -472,6 +476,7 @@ const FE_MODE_SQL = 'modeSql'; ...@@ -472,6 +476,7 @@ const FE_MODE_SQL = 'modeSql';
// TODO: Konstante FE_DYNAMIC_UPDATE ueberall einsetzen // TODO: Konstante FE_DYNAMIC_UPDATE ueberall einsetzen
const FE_DYNAMIC_UPDATE = 'dynamicUpdate'; const FE_DYNAMIC_UPDATE = 'dynamicUpdate';
const FE_VALUE = 'value'; const FE_VALUE = 'value';
const FE_CLASS = 'class';
// FormElement columns: via parameter field // FormElement columns: via parameter field
const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
...@@ -496,6 +501,7 @@ const FE_SENDMAIL_REPLY_TO = 'sendMailReplyTo'; // Reply to email address ...@@ -496,6 +501,7 @@ const FE_SENDMAIL_REPLY_TO = 'sendMailReplyTo'; // Reply to email address
const FE_SENDMAIL_FLAG_AUTO_SUBMIT = 'sendMailFlagAutoSubmit'; // on|off - if 'on', suppresses OoO answers from receivers. const FE_SENDMAIL_FLAG_AUTO_SUBMIT = 'sendMailFlagAutoSubmit'; // on|off - if 'on', suppresses OoO answers from receivers.
const FE_SENDMAIL_GR_ID = 'sendMailGrId'; // gr_id: used to classify mail log entries ind table mailLog const FE_SENDMAIL_GR_ID = 'sendMailGrId'; // gr_id: used to classify mail log entries ind table mailLog
const FE_SENDMAIL_X_ID = 'sendMailXId'; // x_id: used to classify mail log entries ind table mailLog const FE_SENDMAIL_X_ID = 'sendMailXId'; // x_id: used to classify mail log entries ind table mailLog
const FE_AUTOFOCUS = 'autofocus'; // value: <none>|0|1 , <none>==1, this element becomes the focus during form load.
// FormElement Types // FormElement Types
......
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