Hide field on update.

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

Hide field on update.

Postby jvinolas » Fri Mar 04, 2011 8:18 am

Hi,

I can hide a field from list, browse, edit, etc... but can't hide it from update. Is it possible to hide a field from update (and from edit)?

This is my fields.ini field definition:

Code: Select all
visibility=hidden
widget:type=hidden
widget:label="Estat soci"
filter=1
order=1
ignore=1



Thanks
jvinolas
 
Posts: 51
Joined: Thu Apr 15, 2010 12:31 am

Re: Hide field on update.

Postby shannah » Fri Mar 04, 2011 10:51 am

If you update your actions/copy_replace.php file with the one from SVN:
http://weblite.ca/svn/dataface/core/tru ... eplace.php

It adds support for the visibility:update directive in the fields.ini file.
e.g.
Code: Select all
visibility=hidden
widget:type=hidden
widget:label="Estat soci"
filter=1
order=1
ignore=1
visibility:update=hidden
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Hide field on update.

Postby jvinolas » Fri Mar 11, 2011 2:32 am

Hi again,

It worked after I updated the action file, thanks.

Now I have another related question: Is it possible to hide a field from update dropdown based on field__permissions() method? I tried to give back a READ_ONLY for that field based on user logged in, that did nothing, cause I could see the field and also update it (??why??).

I also tried to give back an array with 'edit' => 0, that allowed me to show the field on update, but throwed the 'not enough permissions' error as expected.

So, is it possible to give back an array with some kind of parameter as 'visibility:update' => 0 on field__permissions() method?

Thanks again.
jvinolas
 
Posts: 51
Joined: Thu Apr 15, 2010 12:31 am

Re: Hide field on update.

Postby shannah » Fri Mar 11, 2011 10:34 am

Field permissions are a little different than record permissions because whatever is returned from the fieldname__permission() method is applied to the record permissions as a mask. The READ_ONLY() permission only defines what permissions are "permitted" for read only, but doesn't explicitly deny any permissions. For record permissions this works because an omitted permission is the same as "not permitted". However if you use this in a field permission then the results of READ_ONLY() will only be applied as a mask to the existing record permissions - and this won't un-permit anything that was permitted as part of the getPermissions() method.

So for fields, you should either:

1. Start with the NO_ACCESS permission and explicitly add the permissions that you need.
or
2. Simply disallow the 'edit' permission.

e.g.
Code: Select all
function fieldname__permissions($record){
    return array('edit'=>0);
}


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

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