1
votes

I am using CakePHP. I have a form, let's say user profile edit, and I don't want the user to modify the username, but I still want to display it.

I am displaying it using something like:

echo $this->Form->input("username");

This outputs a label named Username and an input text box. I don't want this text box, instead just want another label with the username value.

Have been going through the cook book, but can't find it.

2

2 Answers

4
votes

The value is stored in $this->data[ 'User' ][ 'username' ] (assuming the model's name is "User").

On the other hand if you want to just disable the edit box, use this:

echo $this->Form->input(
    'username',
    array( 'disabled' => 'disabled' )
);
1
votes

You can literally just make an HTML label, and use the value that's passed:

<label for="username">Username:</label><?php echo $this->data['User']['username']; ?>