Turn off "Other..." on select / checkboxes

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

Turn off "Other..." on select / checkboxes

Postby jimr451 » Tue Jul 19, 2011 10:27 am

Hi,

I have some "transient" fields and normal select box relationships set up. But each one on the "edit" screen shows the options, then an "Other..." link which allows you to add another option on the fly. I'd like have those tables edited elsewhere, if at all, and just turn off the "Other..." link.

I looked around, but can't figure out how to do that.

Any ideas?

-Jim
Jim Roberts
Roberts WebForge, Inc.
http://www.robertswebforge.com
jimr451
 
Posts: 20
Joined: Mon Jun 27, 2011 1:46 pm

Re: Turn off "Other..." on select / checkboxes

Postby shannah » Tue Jul 19, 2011 10:36 am

That option is subject to the 'add new related record' permission, so you can disable it by denying the use the 'add new related record' permission for that relationship. Of course that would also prevent the same user from adding new related records to that relationship in other parts of the interface also.

You could also use CSS to just hide this link if you don't intend to disable the action entirely for the user but just want to hide it from the interface. Use permissions to solve permission related problems and CSS/preferences to solve UI related problems, and try hard to understand whether a problem is related to UI or permissions before making a choice.

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

Re: Turn off "Other..." on select / checkboxes

Postby jimr451 » Tue Jul 19, 2011 11:32 am

Thanks - that pointed me in the right direction. I added a function in my [tablename].php file:


Code: Select all
function rel_atmospheres__permissions(&$record) {
  return array(
            'add new related record' => 0
            );
}


(the relationship was named 'atmospheres' - this seemed to do the trick, and I think the "admin" can still edit the atmospheres table directly to add choices.)

Thanks,

-Jim
Jim Roberts
Roberts WebForge, Inc.
http://www.robertswebforge.com
jimr451
 
Posts: 20
Joined: Mon Jun 27, 2011 1:46 pm

Re: Turn off "Other..." on select / checkboxes

Postby shannah » Tue Jul 19, 2011 11:39 am

That's the right idea. Generally in my applications I try to give my admin user full access - and limit access to other users. Assuming you have defined a function called isAdmin() that returns true if the currently logged in user is an admin user, you could alter the code as follows to make admins exempt from these permission limitations:
Code: Select all
function rel_atmospheres__permissions(&$record) {
    if ( isAdmin() ) return null;
    return array(
            'add new related record' => 0
            );
}


Best practice is to actually deny all access to users at the global level (except admins), and then add access at the table, field, and relationship levels explicitly to other users as required. That minimizes the chances of accidentally giving users access to things they shouldn't have access to.

-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 19 guests

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