Hide specific fields based on checkbox in record

A place to discuss development of the Xataface core.

Hide specific fields based on checkbox in record

Postby ururk » Mon Nov 01, 2010 12:36 pm

I'm having trouble finding where to set this - either in an Application delegate, or in an ini file.

As an example, I have a table... it contains 10 columns. 4 columns are public, and 5 are private if the user wants them to be. The user checks a checkbox if they want to show those 4 columns. If not, a helpful message "Not shown" should display.

Is this an ini setting, or in the delegate? Or is this beyond what xataface can provide without modifying core files?

Thanks!
ururk
 
Posts: 18
Joined: Mon Nov 01, 2010 12:31 pm

Re: Hide specific fields based on checkbox in record

Postby ururk » Mon Nov 01, 2010 1:26 pm

OK, I think I am on the right track, though I wish this is something I could set in an ini file.

It looks like I'm going to have to create two functions, both set in the table delegate class:

1) fieldname__permissions
2) fieldname__display

What is the structure of $record?
ururk
 
Posts: 18
Joined: Mon Nov 01, 2010 12:31 pm

Re: Hide specific fields based on checkbox in record

Postby ururk » Mon Nov 01, 2010 1:53 pm

I feel like a fool... but want to post my solution. This function goes in the table delegate:
Code: Select all
   function fieldname__display(&$record) {
      if ($record->_values['ShowColumn'] == 1) {
         return $record->_values['fieldname'];
      } else {
         return 'Informaton Witheld';
      }
   }


Thats it. I'll probably write this to be a bit more generic so I can apply this routine to several columns which need hiding.
ururk
 
Posts: 18
Joined: Mon Nov 01, 2010 12:31 pm

Re: Hide specific fields based on checkbox in record

Postby shannah » Wed Nov 03, 2010 10:15 am

The display() method is already subject to the "view" permission. If you deny users permission to that field, then display() will show "NO ACCESS"

Code: Select all
function fieldname__permissions($record){
    if ( /* don't show this field */){
        return array('view'=>0);
    }
    return null;
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Developers

Who is online

Users browsing this forum: No registered users and 6 guests

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