I have a Cakephp 1.3 form that allows users to edit profile data. But some data in forms should be read only (sometimes).
I am the only option for echoing and formatting the contents of a field in a read-only case or there is a flag in the form of Cake that allows only read-only fields. Ideally, read-only fields will be grayed out like other interfaces.
echo $this->Form->create('User', array('url' => array('controller' => 'User', 'action'=>'editUser')));
echo $this->Form->input('id', array('type'=>'hidden'));
If (!isset($IsAdmin)) {
echo $this->Form->input('username', array('label' => __d('users', 'User',true)));
} else {
echo $this->Form->input('username', array('label' => __d('users', 'User',true)));
}
... more fields here
echo $this->Form->end(__d('users', 'Submit',true));
source
share