Page 1 of 1

Hide field on update.

PostPosted: Fri Mar 04, 2011 8:18 am
by jvinolas
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

Re: Hide field on update.

PostPosted: Fri Mar 04, 2011 10:51 am
by shannah
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

Re: Hide field on update.

PostPosted: Fri Mar 11, 2011 2:32 am
by jvinolas
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.

Re: Hide field on update.

PostPosted: Fri Mar 11, 2011 10:34 am
by shannah
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