Immutable fields

Posted:
Wed Apr 16, 2008 1:16 pm
by marksawers
I'd like to display fields with immutable values, e.g. a primary key, either as static labels or as a disabled form input element. The widge:type=static shows it as a label, but when I save it complains that the field value is missing. I can't use the widget:atts:style either, as input elements apparently don't take direction on disabled state from style.
Suggestions? Thanks!

Posted:
Wed Apr 16, 2008 2:02 pm
by shannah
Best to use parmissions for this.
e.g. if your field name is 'fooID', then define a method in your delegate class:
- Code: Select all
function fooID__permissions(&$record){
return Dataface_PermissionsTool::READ_ONLY();
}
Immutable fields

Posted:
Wed Apr 16, 2008 2:32 pm
by marksawers
That works for edit but not for add. The field on the create new record form has no input! I guess if my PK was an auto-increment this would work, but in this case it is not.
Any other ideas? Thanks!

Posted:
Wed Apr 16, 2008 2:36 pm
by shannah
So you need this field to be editable on ADD but not after it has been added?
- Code: Select all
function fooID__permissions(&$record){
$perms = Dataface_PermissionsTool::READ_ONLY();
$perms['new'] = 1;
return $perms;
}