Tagged: ,

Viewing 4 reply threads
  • Author
    Posts
    • #3487
      jcrist
      Member

      I’ve setup some user fields, one of which is only editable by the admin:
      if($role != 'administrator') $args['attributes']['disabled'] = true;

      However when the user updates their profile, the value gets deleted. I’ve tried adding the value field but the same thing happens. Bug?

    • #3488
      Steve
      Keymaster

      @jcrist– Do you want the non-admin to see the field, but just have it disabled? Or should they not see it at all?

    • #3489
      jcrist
      Member

      Correct, user should be able to see the field but it is disabled.

      Not a big deal as I ended up hiding the field for non-admins but still seems strange that the value disappears.

    • #3490
      Steve
      Keymaster

      @jcristBrowsers don’t submit data for disabled fields. Try readonly instead.

      Also, you can easily do this at the field level. Use this for your attributes:

      	 ,'attributes' => array(
      	   'readonly' => piklist_user::current_user_role('administrator') ? '' : 'readonly'
      	 )
      
    • #3491
      jcrist
      Member

      Bingo, thanks Steve.

Viewing 4 reply threads
  • The topic ‘Disabled Value’ is closed to new replies.