Short version: How can we toggle field "X" from being a Select (popup) for
Admin users, to being a Hidden (nothing visible, but the value is
maintained) for Manager users?

Long version:

We have three levels of user-roles (*admins* can do everything,
*managers*can do a lot,
*readonly* can do very little). Admins get to specify user roles for all
users (even other admins), but managers (level two) only get to edit
readonly users and we don't want them to elevate any such users to being
managers (or worse, admins).

    package MyApp::Controller::Admin::Person;
    #...
    $self->form( MyApp::Form::Admin::Person->new( ctx => $c ) );

    package MyApp::Form::Admin::Person;
    #....
    sub set_active {
        my $self = shift;
        $self->inactive(['role'])
            unless $self->ctx->user->is_admin;
    }

Trying to use ctx so we could pass $c and later test it in the form's
"set_active" method throws an exception because of ctx being undefined.

    package MyApp::Controller::Admin::Person;
    #...
    unless ( $c->user->is_admin ) {
#       $self->form->inactive(['role']);
#       $self->form->field('role')->widget('hidden');
#       $self->form->field('role')->type('Hidden');
    }

So instead we've tried making the field inactive (no apparent effect at
all), switching to a different widget (field completely disappears) or
different type (field completely disappears).

Pointers?

-- 
“Waiting for perfect is never as smart as making progress.”  -- Seth Godin
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to