Cakephp’s Auth Component – add new users, drop down menu for ENUM

In the Football Stars application, every unauthenticated visitor can register and create account. The non-logged users have access to add users view:
add view

During registration, the non-logged user must fill in the ‘Name’, ‘Username’, ‘Password’ and ‘Password Confirmation’ inputs but cannot choose role. The default role for each new user created by unauthenticated visitors is ‘user’.
Non-logged user’s add view:
add view2

The admin can also create new users, but admin can set up new user’s role (‘user’ or ‘admin’ role):
add view3

The public function that checks if logged user’s role is ‘admin’:
add view4

Admin add (register new users) view:
add view5

Drop Down List for ENUM – Revision

To create FormEnum the first file that has to be modified is the UsesController.php :

After that user add.ctp file was altered:

Unfortunately refreshing the user add page returns error:

In order to fix this error FormEnumHelper.php helper has to be added to app/View/Helper.
Once this file has been added to the appropriate folder on the server admin can see drop-down menu for user roles:

To display drop-down disabled list for non-admin users, the following else statement was added to the already existing if statement (in add.ctp and edit.ctp files):

Right now new users can see disabled role during registration process:


And an existing non-admin users can also see disabled role on edit user profile page: