Locking fields

Skip to end of metadata
Go to start of metadata

Sometimes it's useful that a field cannot be modified/deleted in the class editor. Especially if a class is created by a plugin.

pimcore offers the possibility to lock a field programmatically, you can call the method setLocked() on every Object_Class_Data object.

Example

The following example will lock every field inside the class with the ID 7.

$class = Object_Class::getById(7);
$fields = $class->getFielddefinitions();


foreach ($fields as $field) {
   $field->setLocked(true);
}


$class->save();

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.