5 years ago
5
Topic

Hello!

Is there a way to set for one field two or more restrictions? For exemple I want to show a field for registred users but not to show it on mobile devices. 

I think I can reach it by using beforestore plagin, can anyone help how to write correct condition there? 

thnx! 

Get a VIP membership
4229 Posts
Kadministrator
5 years ago
4
Level 1

At the moment this is unfortunately not possible using built-in capabilities, only way would be to use beforeRender and disable the field using code.

5 years ago
3
Level 2

Thanks Klas, 

I've got beforeRender plugin, could you give a piece of code for example how to make a conditions with restrictions in beforeRender, because I havent found it on the forum....

Thnx!

4229 Posts
Kadministrator
5 years ago
2
Level 3

Depends on he view you are in - if this is content setting $fields['yourf_field_name']->restricted = 1; will probably do, on the form view you will also need to set ->form property to empty string, you could also try to unset $fields['yourf_field_name'], but I'm not sure of that might cause some error.

5 years ago
1
Level 4

Thanks Klas! 

I need to unset a field in content view for some groups and on mobile phones, I've been trying to play with BeforeRender but cannot get it work, I'm still not clear how to control the restrictions,  you gave this example  $fields['yourf_field_name']->restricted = 1; 

What does mean 1 in your example? 

For my purpose in admin panel I have set one restriction - "groups permissions", now how to set the second restriction for mobiles devices?


Thanks for any help! 

 

 

4229 Posts
Kadministrator
5 years ago
0
Level 5

If you set field's restricted property to 1 it should not be rendered. If this this not happening try var_dump on $fields['yourf_field_name'] to see what is in the object, than try manipulating it's properties like html e.g. by setting it to empty string.

Get a Book for SEBLOD