To make a field dynamically read only, use the CodeCharge Component Attributes feature. Here are the steps:

if ($RT_TABLE->EditMode)
{
	$Component->Attributes->SetValue('readonly', 'readonly');
}

Again where $RT_TABLE is the form name