yii-user admin fields

Hello,

How can I change yii-user to allow admin to see hidden fields?

I want fields added to the user that only admins can modify the values.

Thanks

can you describe clearly what exactly you want!!!

Yes,

I want to add a hidden field and allow only admins to change the value.

Example:

I want to add a field called PriceLevel that is hidden and assign values based on different users.

why you not try that field on page ( that only admin can access ) and change value , on that page no need to use hidden field , as you use that field as hidden for normal user.

if this can’t help, please more specify about your requirment.

I do not want the user to be able to see it.

Also, I am getting sql error because the birthdate field is blank.

Thanks




CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' for column 'birthday' at row 1. The SQL statement executed was: INSERT INTO `tbl_profiles` (`lastname`, `firstname`, `birthday`, `company`, `phone`, `PriceLevel`, `user_id`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6) 



yes as you use this field as hidden , user can’t see it ,

but use same field for admin as admin can update it simple …

and can’t judge what kind of sql error you got , cause you not specifying things clearly.

and please check values post successfully, you said date is null … please use $_POST($[Model]) or $_POST($[Model][‘date’]).

Any field I mark hidden, when I bring up the record to edit as an admin, the field is not shown.

The sql error I am getting is because I have bi value in the Birthdate. If I enter a value, it works.

Thanks

just can’t understand what you want to do. <_<

On the Manage Profile screen under visible.

Choices are For All, Registered Users, Only Owner, Hidden.

If I create a field and assign it Hidden, the admin cannot see this field when he edits a users profile.

I want the admin to be able to edit this field, as the user must not see this.

PriceLevel=A

PriceLevel=B

PriceLevel=C

The user must not be able to control the PriceLevel.

This is in the yii-user extension

The only thing I can see to do is create my own model and crud code against these tables.

for this you have to use user role , if user is admin you can make field as textField or else and if user is normal user you can use field as hidden ,

just code to check the user role and define input element … simple.

Do you have an example?

I am not familiar with using user role in yii-user.

Thanks

This seems to work.




ProfileField.php

public function scopes()

    {

        return array(

		 'forAdmin'=>array(

                //'condition'=>'visible='.self::VISIBLE_ALL,

                'order'=>'position',

            ),

            'forAll'=>array(

                'condition'=>'visible='.self::VISIBLE_ALL,

                'order'=>'position',

            ),

            'forUser'=>array(

                'condition'=>'visible>='.self::VISIBLE_REGISTER_USER,

                'order'=>'position',

            ),

            'forOwner'=>array(

                'condition'=>'visible>='.self::VISIBLE_ONLY_OWNER,

                'order'=>'position',

            ),

            'forRegistration'=>array(

                'condition'=>'required='.self::REQUIRED_NO_SHOW_REG.' OR required='.self::REQUIRED_YES_SHOW_REG,

                'order'=>'position',

            ),

            'sort'=>array(

                'order'=>'position',

            ),

        );

    }






Profile.php

	public function getFields() {

		// Add Next line

	if(UserModule::isAdmin()) {

			$this->_model=ProfileField::model()->forAdmin()->findAll();

			return $this->_model;

		}

		// Add End

		if ($this->regMode) {

			if (!$this->_modelReg)

				$this->_modelReg=ProfileField::model()->forRegistration()->findAll();

			return $this->_modelReg;

		} else {

			if (!$this->_model)

				$this->_model=ProfileField::model()->forOwner()->findAll();

			return $this->_model;

		}

	}