getTitle() vs. titleColumn()

A place for users and developers of the Xataface to discuss and receive support.

getTitle() vs. titleColumn()

Postby ADobkin » Thu Jun 30, 2011 11:26 am

I am having some display problems with both getTitle() and titleColumn() delegate class functions and could use a little advice.

I have a single table that has both a company name and a contact (person) name field. There are some entries that have only a company name entered, some that have only a contact name, and some that have both. To avoid confusion, especially when selecting to add as a related record in other tables, I would like to display either or both if they are available, so I have the following:

Code: Select all
        function getTitle(&$record){
                if ($record->val('contactName') == '') {
                        return $record->val('companyName');
                } elseif ($record->val('companyName') == '') {
                        return $record->val('contactName');
                } else {
                        return $record->val('companyName').' - '.$record->val('contactName');
                }
        }


When I use that function by itself, it only displays the company name, not the contact name. So, I added the following:

Code: Select all
        function titleColumn(){
                return "CONCAT(companyName, ' -- ', contactName)";
        }


Now, both functions work, but they appear differently. Notice that the getTitle function uses a single dash in the concatenation, but the titleColumn function uses two dashes (--) so I could tell the difference.

The getTitle function does now display both the company name and the client name as it should. Note that this is using the exact same function code that didn't work above. However, it only appears in the record title, but it is not used for the drop-down record selection lists.

Further, the titleColumn function doesn't display properly in this case. It does show the company name and the contact name for most entries, but it just shows blank lines for those entries that have any symbols in the name, like dash (-) and ampersand (&). Is it possible to escape these entries somehow? I tried using the php htmlspecialchars function, but that just gave me an error and wouldn't load the page at all.

Any suggestions would be most appreciated!

Thanks,
Alan
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Return to Xataface Users

Who is online

Users browsing this forum: Google [Bot] and 27 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved