BUG 6828 "Request that the address and label of link fields in..." SOLVED
- New feature
- Request that the address and label of link fields in DynaForms can be
set and saved using case variables
- Populate links in a grid via trigger
- Added this new funcionality
- Take into account the following (examples):
> Triggers
* Populate a link field
@@MyLink = "http://www.php.net";
@@MyLink_label = "Read about PHP";
* Populate links in a grid
@=MYGRID = array();
$i = 1;
$rs = $stmt->executeQuery("SELECT USR_USERNAME FROM USERS", ResultSet::FETCHMODE_ASSOC);
while ($rs->next()) {
$row = $rs->getRow();
@=MYGRID[$i] = array(
"MyField" => $row["USR_USERNAME"],
"MyLink" => "http://www.php.net",
"MyLink_label" => "Read about PHP, $i"
);
$i = $i + 1;
}
> JavaScript, populate a link field:
getField("MyLink").href = "http://www.php.net";
getField("MyLink").innerHTML = "Read about PHP";
* Available from version 2.0.46
This commit is contained in:
@@ -3060,18 +3060,22 @@ var validateForm = function(sRequiredFields) {
|
||||
}
|
||||
else {
|
||||
var arrayForm = document.getElementsByTagName("form");
|
||||
var inputAux;
|
||||
var id = "";
|
||||
var i1 = 0;
|
||||
var i2 = 0;
|
||||
|
||||
for (var i = 0; i <= arrayForm.length - 1; i++) {
|
||||
var frm = arrayForm[i];
|
||||
for (i1 = 0; i1 <= arrayForm.length - 1; i1++) {
|
||||
var frm = arrayForm[i1];
|
||||
|
||||
for (var i = 0; i <= frm.elements.length - 1; i++) {
|
||||
var elem = frm.elements[i];
|
||||
for (i2 = 0; i2 <= frm.elements.length - 1; i2++) {
|
||||
var elem = frm.elements[i2];
|
||||
|
||||
if (elem.type == "checkbox" && elem.disabled && elem.checked) {
|
||||
var id = elem.id + "_";
|
||||
id = elem.id + "_";
|
||||
|
||||
if (!document.getElementById(id)) {
|
||||
var inputAux = document.createElement("input");
|
||||
inputAux = document.createElement("input");
|
||||
inputAux.type = "hidden";
|
||||
inputAux.id = id;
|
||||
inputAux.name = elem.name;
|
||||
@@ -3081,7 +3085,47 @@ var validateForm = function(sRequiredFields) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var arrayLink = frm.getElementsByTagName("a");
|
||||
|
||||
for (i2 = 0; i2 <= arrayLink.length - 1; i2++) {
|
||||
var link = arrayLink[i2];
|
||||
|
||||
if (typeof link.id != "undefined" && link.id != "" && link.id != "form[DYN_BACKWARD]" && link.id != "form[DYN_FORWARD]") {
|
||||
var strHtml = link.parentNode.innerHTML;
|
||||
|
||||
strHtml = stringReplace("\\x0A", "", strHtml); //\n 10
|
||||
strHtml = stringReplace("\\x0D", "", strHtml); //\r 13
|
||||
strHtml = stringReplace("\\x09", "", strHtml); //\t 9
|
||||
|
||||
if (/^.*pm:field.*$/.test(strHtml)) {
|
||||
id = link.id + "_";
|
||||
|
||||
if (!document.getElementById(id)) {
|
||||
var strAux = link.id.replace("form[", "");
|
||||
strAux = strAux.substring(0, strAux.length - 1);
|
||||
|
||||
inputAux = document.createElement("input");
|
||||
inputAux.type = "hidden";
|
||||
inputAux.id = id;
|
||||
inputAux.name = link.id;
|
||||
inputAux.value = link.href;
|
||||
|
||||
frm.appendChild(inputAux);
|
||||
|
||||
inputAux = document.createElement("input");
|
||||
inputAux.type = "hidden";
|
||||
inputAux.id = id + "label";
|
||||
inputAux.name = "form[" + strAux + "_label]";
|
||||
inputAux.value = link.innerHTML;
|
||||
|
||||
frm.appendChild(inputAux);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1214,7 +1214,8 @@ var emailInvalidMessage="";for(j=0;j<fielEmailInvalid.length;j++){emailInvalidMe
|
||||
var systemMessaggeInvalid="";if(invalid_fields.length>0){systemMessaggeInvalid+="\n \n"+G_STRINGS.ID_REQUIRED_FIELDS+": \n \n [ "+sMessage+" ]";}
|
||||
if(fielEmailInvalid.length>0){systemMessaggeInvalid+="\n \n"+G_STRINGS.ID_VALIDATED_FIELDS+": \n \n [ "+emailInvalidMessage+" ]";}
|
||||
alert(systemMessaggeInvalid);return false;}
|
||||
else{var arrayForm=document.getElementsByTagName("form");for(var i=0;i<=arrayForm.length-1;i++){var frm=arrayForm[i];for(var i=0;i<=frm.elements.length-1;i++){var elem=frm.elements[i];if(elem.type=="checkbox"&&elem.disabled&&elem.checked){var id=elem.id+"_";if(!document.getElementById(id)){var inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=elem.name;inputAux.value=elem.value;frm.appendChild(inputAux);}}}}
|
||||
else{var arrayForm=document.getElementsByTagName("form");var inputAux;var id="";var i1=0;var i2=0;for(i1=0;i1<=arrayForm.length-1;i1++){var frm=arrayForm[i1];for(i2=0;i2<=frm.elements.length-1;i2++){var elem=frm.elements[i2];if(elem.type=="checkbox"&&elem.disabled&&elem.checked){id=elem.id+"_";if(!document.getElementById(id)){inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=elem.name;inputAux.value=elem.value;frm.appendChild(inputAux);}}}
|
||||
var arrayLink=frm.getElementsByTagName("a");for(i2=0;i2<=arrayLink.length-1;i2++){var link=arrayLink[i2];if(typeof link.id!="undefined"&&link.id!=""&&link.id!="form[DYN_BACKWARD]"&&link.id!="form[DYN_FORWARD]"){var strHtml=link.parentNode.innerHTML;strHtml=stringReplace("\\x0A","",strHtml);strHtml=stringReplace("\\x0D","",strHtml);strHtml=stringReplace("\\x09","",strHtml);if(/^.*pm:field.*$/.test(strHtml)){id=link.id+"_";if(!document.getElementById(id)){var strAux=link.id.replace("form[","");strAux=strAux.substring(0,strAux.length-1);inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=link.id;inputAux.value=link.href;frm.appendChild(inputAux);inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id+"label";inputAux.name="form["+strAux+"_label]";inputAux.value=link.innerHTML;frm.appendChild(inputAux);}}}}}
|
||||
return true;}};var getObject=function(sObject){var i;var oAux=null;var iLength=__aObjects__.length;for(i=0;i<iLength;i++){oAux=__aObjects__[i].getElementByName(sObject);if(oAux){return oAux;}}
|
||||
return oAux;};var saveAndRefreshForm=function(oObject){if(oObject){oObject.form.action+='&_REFRESH_=1';oObject.form.submit();}
|
||||
else{var oAux=window.document.getElementsByTagName('form');if(oAux.length>0){oAux[0].action+='&_REFRESH_=1';oAux[0].submit();}}};var saveForm=function(oObject){if(oObject){ajax_post(oObject.form.action,oObject.form,'POST');}
|
||||
|
||||
@@ -236,6 +236,14 @@ class Form extends XmlForm
|
||||
foreach ($newValues[$k] as $j => $item) {
|
||||
if ($this->fields[$k]->validateValue( $newValues[$k][$j], $this )) {
|
||||
$this->values[$k][$j] = $newValues[$k][$j];
|
||||
|
||||
switch ($this->fields[$k]->type) {
|
||||
case "link":
|
||||
if (isset($newValues[$k . "_label"][$j])) {
|
||||
$this->values[$k . "_label"][$j] = $newValues[$k . "_label"][$j];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sizeof( $this->values[$k] ) === 1) && ($v->type !== 'grid') && isset( $this->values[$k][0] )) {
|
||||
@@ -247,6 +255,14 @@ class Form extends XmlForm
|
||||
} else {
|
||||
if ($this->fields[$k]->validateValue( $newValues[$k], $this )) {
|
||||
$this->values[$k] = $newValues[$k];
|
||||
|
||||
switch ($this->fields[$k]->type) {
|
||||
case "link":
|
||||
if (isset($newValues[$k . "_label"])) {
|
||||
$this->values[$k . "_label"] = $newValues[$k . "_label"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,7 +347,6 @@ class Form extends XmlForm
|
||||
if (($v->type != 'submit')) {
|
||||
if ($v->type != 'file') {
|
||||
if (array_key_exists( $k, $newValues )) {
|
||||
|
||||
switch ($v->type) {
|
||||
case 'radiogroup':
|
||||
$values[$k] = $newValues[$k];
|
||||
@@ -414,6 +429,10 @@ class Form extends XmlForm
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "link":
|
||||
$values[$k] = $newValues[$k];
|
||||
$values[$k . "_label"] = $newValues[$k . "_label"];
|
||||
break;
|
||||
case 'grid':
|
||||
foreach ($newValues[$k] as $j => $item) {
|
||||
if (is_array( $item )) {
|
||||
@@ -457,6 +476,10 @@ class Form extends XmlForm
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "link":
|
||||
$values[$k][$j] = $newValues[$k][$j];
|
||||
$values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"];
|
||||
break;
|
||||
default:
|
||||
//If there are no dropdowns previously setted and the evaluated field is not a dropdown
|
||||
//only then rewritte the $values
|
||||
|
||||
@@ -2495,19 +2495,54 @@ class XmlForm_Field_Link extends XmlForm_Field
|
||||
* @param string value
|
||||
* @return string
|
||||
*/
|
||||
public function render ($value = null, $owner = null)
|
||||
public function render($value = null, $label = null, $owner = null, $row = -1)
|
||||
{
|
||||
$onclick = G::replaceDataField( $this->onclick, $owner->values );
|
||||
$link = G::replaceDataField( $this->link, $owner->values );
|
||||
$target = G::replaceDataField( $this->target, $owner->values );
|
||||
$value = G::replaceDataField( $this->value, $owner->values );
|
||||
$label = G::replaceDataField( $this->label, $owner->values );
|
||||
$html = '<a class="tableOption" href=\'' . $this->htmlentities( $link, ENT_QUOTES, 'utf-8' ) . '\'';
|
||||
$html .= 'id="form[' . $this->name . ']" name="form[' . $this->name . ']" style="' . htmlentities( $this->style, ENT_QUOTES, 'utf-8' ) . '" ';
|
||||
$html .= (($this->onclick) ? ' onclick="' . htmlentities( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : '');
|
||||
$html .= (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>';
|
||||
$html .= $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . '</a>';
|
||||
$html .= $this->renderHint();
|
||||
$id = null;
|
||||
$v = null;
|
||||
|
||||
switch ($owner->type) {
|
||||
case "grid":
|
||||
$id = $owner->name . "][" . $row . "][" . $this->name;
|
||||
$v = (isset($owner->values[$owner->name][$row]))? $owner->values[$owner->name][$row] : array();
|
||||
break;
|
||||
default:
|
||||
$id = $this->name;
|
||||
$v = $owner->values;
|
||||
break;
|
||||
}
|
||||
|
||||
$link = (!empty($value))? $value : G::replaceDataField($this->link, $v);
|
||||
$labelAux1 = (!empty($label))? $label : G::replaceDataField($this->label, $v);
|
||||
$labelAux2 = (!empty($label))? $label : G::replaceDataField($this->value, $v);
|
||||
$onclick = G::replaceDataField($this->onclick, $v);
|
||||
$target = G::replaceDataField($this->target, $v);
|
||||
|
||||
$html = "<a class=\"tableOption\" href=\"" . $this->htmlentities($link, ENT_QUOTES, "utf-8") . "\"";
|
||||
$html = $html . " id=\"form[$id]\" name=\"form[$id]\" pm:field=\"pm:field\"";
|
||||
$html = $html . (($this->onclick)? " onclick=\"" . htmlentities($onclick, ENT_QUOTES, "utf-8") . "\"" : null);
|
||||
$html = $html . (($this->target)? " target=\"" . htmlentities($target, ENT_QUOTES, "utf-8") . "\"" : null);
|
||||
|
||||
switch ($owner->type) {
|
||||
case "grid":
|
||||
if ($this->mode == "view") {
|
||||
$html = $html . " style=\"color: #006699; text-decoration: none; font-weight: normal;\"";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$html = $html . " style=\"" . htmlentities($this->style, ENT_QUOTES, "utf-8") . "\"";
|
||||
break;
|
||||
}
|
||||
|
||||
$html = $html . ">" . $this->htmlentities(($this->value == "")? $labelAux1 : $labelAux2, ENT_QUOTES, "utf-8") . "</a>";
|
||||
|
||||
switch ($owner->type) {
|
||||
case "grid":
|
||||
break;
|
||||
default:
|
||||
$html = $html . $this->renderHint();
|
||||
break;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
@@ -2518,30 +2553,22 @@ class XmlForm_Field_Link extends XmlForm_Field
|
||||
* @param $owner
|
||||
* @return <array>
|
||||
*/
|
||||
public function renderGrid ($values = array(), $owner = null)
|
||||
public function renderGrid($value = array(), $label = array(), $owner = null)
|
||||
{
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
foreach ($values as $v) {
|
||||
$_aData_ = (isset( $owner->values[$owner->name][$r] ) ? $owner->values[$owner->name][$r] : array ());
|
||||
$onclick = G::replaceDataField( $this->onclick, $_aData_ );
|
||||
$link = G::replaceDataField( $this->link, $_aData_ );
|
||||
$target = G::replaceDataField( $this->target, $_aData_ );
|
||||
$value = G::replaceDataField( $this->value, $_aData_ );
|
||||
$label = G::replaceDataField( $this->label, $_aData_ );
|
||||
$html = '<a class="tableOption" href=\'' . $this->htmlentities( $link, ENT_QUOTES, 'utf-8' ) . '\'';
|
||||
$html .= 'id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"';
|
||||
$html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"';
|
||||
$html .= (($this->onclick) ? ' onclick="' . htmlentities( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : '');
|
||||
$html .= (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : '');
|
||||
if ($this->mode == 'view') {
|
||||
$html .= 'style="color: #006699; text-decoration: none;font-weight: normal;"';
|
||||
$arrayResult = array();
|
||||
$row = 1;
|
||||
|
||||
foreach ($value as $index => $v) {
|
||||
$arrayResult[] = $this->render(
|
||||
(isset($value[$index]))? $value[$index] : null,
|
||||
(isset($label[$index]))? $label[$index] : null,
|
||||
$owner,
|
||||
$row
|
||||
);
|
||||
$row = $row + 1;
|
||||
}
|
||||
$html .= '>' . $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . '</a>';
|
||||
$result[] = $html;
|
||||
$r ++;
|
||||
}
|
||||
return $result;
|
||||
|
||||
return $arrayResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5246,7 +5273,18 @@ class xmlformTemplate extends Smarty
|
||||
}
|
||||
$result['form'][$k] = $form->fields[$k]->renderGrid( $aAux, $form );
|
||||
} else {
|
||||
$result['form'][$k] = $form->fields[$k]->render( $value, $form );
|
||||
switch ($v->type) {
|
||||
case "link":
|
||||
$result["form"][$k] = $form->fields[$k]->render(
|
||||
$value,
|
||||
(isset($form->values[$k . "_label"]))? $form->values[$k . "_label"] : null,
|
||||
$form
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$result["form"][$k] = $form->fields[$k]->render($value, $form);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*if (isset ( $form->owner )) {
|
||||
@@ -5270,6 +5308,13 @@ class xmlformTemplate extends Smarty
|
||||
case "file":
|
||||
$result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form, $therow );
|
||||
break;
|
||||
case "link":
|
||||
$result["form"][$k] = $form->fields[$k]->renderGrid(
|
||||
$value,
|
||||
(isset($form->values[$k . "_label"]))? $form->values[$k . "_label"] : array(),
|
||||
$form
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form );
|
||||
break;
|
||||
|
||||
@@ -387,10 +387,10 @@ function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields
|
||||
$aFields[] = array ('sName' => 'PIN','sType' => 'system','sLabel' => 'System variable'
|
||||
);
|
||||
}
|
||||
$aInvalidTypes = array ('title','subtitle','link','file','button','reset','submit','javascript'
|
||||
);
|
||||
$aMultipleSelectionFields = array ('listbox','checkgroup','grid'
|
||||
);
|
||||
|
||||
$aInvalidTypes = array("title", "subtitle", "file", "button", "reset", "submit", "javascript");
|
||||
$aMultipleSelectionFields = array("listbox", "checkgroup", "grid");
|
||||
|
||||
if ($bIncMulSelFields != 0) {
|
||||
$aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user