Showing a field based on the type of authenticated user

pnicolau - 5 months ago

Hi everyone, i am just started testing pyrocms, so far i am enjoying it alot.

Is it possible to show or hide a field based of the type of user that is authenticated, for example show the field "internal_comments" only to admin and salesmen in the admin form or in public form.

I was wondering if there is any option that enable this functionality in the form builder or in a stream migration or other way of doing this.

Best regards Pedro Nicolau

ryanthompson - 5 months ago

Hey there! Glad you're enjoying yourself ^_^

You can limit / define fields dynamically using a "field handler". If you have FooFormBuilder the handler would be FooFormFields and sit right next to it. The handler accepts the $builder in it's handle method.. From there you can do $builder->setFields($fields) dynamically.

Check out this example:

ryanthompson - 5 months ago

PS: You can do this for any UI components.