Hide specific fields based on checkbox in record

Posted:
Mon Nov 01, 2010 12:36 pm
by ururk
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!
Re: Hide specific fields based on checkbox in record

Posted:
Mon Nov 01, 2010 1:26 pm
by ururk
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?
Re: Hide specific fields based on checkbox in record

Posted:
Mon Nov 01, 2010 1:53 pm
by ururk
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.
Re: Hide specific fields based on checkbox in record

Posted:
Wed Nov 03, 2010 10:15 am
by shannah
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;
}