Sanfly
Sanfly

Reputation: 1029

CakeDC Users - Custom Configuration issues

I've added a permission to my permissions.php file: Users.Username.displayed = true/false so that I can decide whether or not I want to use usernames, or just stick to email + real names depending on my application.

I've got this all set up and working well for registering users, and it does all the right things in terms of field validation etc whether or not it is set to display.

Now I want to hide/show the field in my CRUD files too (index, add, edit) but I cant seem to get it to work.

At the top of my SimpleCrudTrait.php file I added

use Cake\Core\Configure;

but in my view Templates (index, add, edit) if I try to call

if(Configure::read('Users.Username.displayed'){ ...

I get an error

Class 'Configure' not found

I can't figure out why this is working for register but not the other pages?

Upvotes: 0

Views: 61

Answers (1)

Greg Schmidt
Greg Schmidt

Reputation: 5099

You've presumably not included the use line in your templates. It needs to be present in every file where you want to reference the Configure class. Read up on PHP namespaces for more details.

Upvotes: 0

Related Questions