HREF Field with lookup table and multiple display fields

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
tberg
User
Posts: 13

HREF Field with lookup table and multiple display fields

Post by tberg »

I have a field address_id that is lookup table from address table. The display fields are address, city, state, zip. I want this field to be a link to google maps. For view tag I have the following:
HREF Field: address_id
Original field value: <unchecked>

This works fine in List and View pages. But in Edit page I get the following warning at the top of the page:
Notice: Array to string conversion in C:\xampp\htdocs\wwdb\phpfn14.php on line 7007

I am using v2018.0.6.

Thanks,
Todd


arbei
User
Posts: 9292

Post by arbei »

Can you post the code around 7007 here?

Also, post your settings for the Edit Tag for the field.


tberg
User
Posts: 13

Post by tberg »

Edit Tag
Select
Use Lookup Table
Tablename: address
Link field: id
Display field #1: address
Display field #2: city
Display field #3: zip

phpfn14.php:
Around 7007 is this function:
// Remove HTML tags from text
function ew_RemoveHtml($str) {
return preg_replace('/<[^>]*>/', '', strval($str));
}

Which is used by this function:
// Get select options HTML
function SelectOptionListHtml($name = "") {
global $Language;
$emptywrk = TRUE;
$curValue = (CurrentPage()->RowType == EW_ROWTYPE_SEARCH) ? ((substr($name,0,1) == "y") ? $this->AdvancedSearch->SearchValue2 : $this->AdvancedSearch->SearchValue) : $this->CurrentValue;
$str = "";
if (is_array($this->EditValue)) {
$arwrk = $this->EditValue;
if ($this->FldSelectMultiple) {
$armultiwrk = (strval($curValue) <> "") ? explode(",", strval($curValue)) : array();
$cnt = count($armultiwrk);
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = FALSE;
for ($ari = 0; $ari < $cnt; $ari++) {
if (ew_SameStr($arwrk[$rowcntwrk][0], $armultiwrk[$ari]) && !is_null($armultiwrk[$ari])) {
$armultiwrk[$ari] = NULL; // Marked for removal
$selwrk = TRUE;
$emptywrk = FALSE;
break;
}
}
if (!$selwrk)
continue;
foreach ($arwrk[$rowcntwrk] as $k => $v)
$arwrk[$rowcntwrk][$k] = ew_RemoveHtml(strval($arwrk[$rowcntwrk][$k]));
$str .= "<option value=\"" . ew_HtmlEncode($arwrk[$rowcntwrk][0]) . "\" selected>" . $this->DisplayValue($arwrk[$rowcntwrk]) . "</option>";
}
} else {
if ($this->UsePleaseSelect)
$str .= "<option value=\"\">" . $this->PleaseSelectText . "</option>";
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
if (ew_SameStr($curValue, $arwrk[$rowcntwrk][0]))
$emptywrk = FALSE;
else
continue;
foreach ($arwrk[$rowcntwrk] as $k => $v)
$arwrk[$rowcntwrk][$k] = ew_RemoveHtml(strval($arwrk[$rowcntwrk][$k]));
$str .= "<option value=\"" . ew_HtmlEncode($arwrk[$rowcntwrk][0]) . "\" selected>" . $this->DisplayValue($arwrk[$rowcntwrk]) . "</option>";
}
}
if ($this->FldSelectMultiple) {
for ($ari = 0; $ari < $cnt; $ari++) {
if (!is_null($armultiwrk[$ari]))
$str .= "<option value=\"" . ew_HtmlEncode($armultiwrk[$ari]) . "\" selected>" . $armultiwrk[$ari] . "</option>";
}
} else {
if ($emptywrk && strval($curValue) <> "")
$str .= "<option value=\"" . ew_HtmlEncode($curValue) . "\" selected>" . $curValue . "</option>";
}
}
if ($emptywrk)
$this->OldValue = "";
return $str;
}


sangnandar
User
Posts: 980

Post by sangnandar »

I guess a string within table address didn't pass ew_RemoveHtml() and call the error.

When you do lookup table, ewlookup*.php will call all display value from the table. A string among these values, then, might have problem with ew_RemoveHtml().
Try to empty the display fields, that is set:
Display field #1: id
and empty the rest.

If the error persist then my guess is wrong.


tberg
User
Posts: 13

Post by tberg »

In this example I do not have any server events. However, I have tried using Row_rendered event to create the HrefValue manually and I get the same result. It seems that when removing html for the field in the edit page, the script first puts the pieces of the ViewValue back into an array. I just don't know how to work around this.


Post Reply