This topic is locked
[SOLVED]

 Customizing labels

7/7/2016 4:15:48 AM
PHPRunner General questions
K
KelvinChua author

Hi Gurus,
Sorry, these are the codes that I am having problems:
///////////// CODES ///////////////////

strTableName, $field_labels, $tables_data;

$sql="select * from settings where tablename='$strTableName'";

$rs = CustomQuery($sql);

while ($data = db_fetch_array($rs)) {

$field_labels[$strTableName][mlang_getcurrentlang()][GoodFieldName($data["field"])]=$data["label"];

if ($data["readonly"]==1)

$tables_data[$strTableName][$data["field"]]["EditFormats"]["edit"]["EditFormat"]="Readonly";

if ($data["required"]==1)

$tables_data[$strTableName][$data["field"]]["EditFormats"]["edit"]["validateAs"]["basicValidate"][0]="IsRequired";

}

///////////// CODES ///////////////////

  1. I checked the $sql, it is correct.
  2. I checked the $data["label"], the content is exactly what I had enter at my 'settings' table.
    But... why is it that the code below does not replace the label??
    $field_labels[$strTableName][mlang_getcurrentlang()][GoodFieldName($data["field"])]=$data["label"];
    Thanks.
    Kelvin Chua

    SINGAPORE

Sergey Kornilov admin 7/7/2016

The problem with this code is that impossible to tell what might be wrong with it. You need to trooubleshoot this code, see what are actual SQL queries executed, what kind of data is returned etc.

K
KelvinChua author 7/7/2016

Hi there,
I checked...
$strTableName will give me public.quotatn
mlang_getcurrentlang() will give me English
GoodFieldName($data["field"]) will give approvedby
Thus,
$field_labels[$strTableName][mlang_getcurrentlang()][GoodFieldName($data["field"])]=$data["label"];
will become...
$field_labels[public.quotatn][English][approvedby]=$data["label"];
When I checked the syntax of $field_labels[public.quotatn][English][approvedby]=$data["label"], I can see that the 'public.' is a syntax error...
I am using PostgreSQL 9.4.
Thanks.
Kelvin Chua

SINGAPORE

Sergey Kornilov admin 7/7/2016

When you hardcode table name or language make sure that you wrapped it with quotes i.e.



$field_labels["public.quotatn"]["English"]["approvedby"]=$data["label"];


Other than that - just impossible to tell what's not working. You need to contact support directly if you need help with this code.

K
KelvinChua author 7/7/2016

Hi Gurus,
Is there anyone who is able to make the following code work for PostgreSQL? I would like to hardcode to change the label for the salesdate field of table quotatn into 'Date Sold'.
$field_labels['public.quotatn']['English']['salesdate']= 'Date Sold';
Many thanks in advance.
Kelvin Chua

SINGAPORE

K
KelvinChua author 7/7/2016

Hi Gurus,
Just in case anyone stranded because of trying to modify the field label, the following should work for PostgreSQL.
///CODE ///
$field_labels[GoodFieldName('public.quotatn')][mlang_getcurrentlang()][GoodFieldName('salesdate')] = 'Date Sold';
///CODE ///
Thanks.
Kelvin Chua

SINGAPORE