Reputation: 2965
In Magento Admin -> Catalog -> Manage Products, I'd like to disable a couple of product fields so that administrators can't edit them.
Essentially turning this:
into this:
Magento pulls the field HTML in via the template at adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml
, via the function getElementHtml()
but I can't find the place where the actual <input>
HTML is being constructed.
Besides, there's probably a more modular way of doing this, rather than just editing the template's HTML.
Any thoughts?
Upvotes: 2
Views: 4778
Reputation: 2965
I discovered a similar question, here, which led me to the solution:
Open up app\design\adminhtml\default\default\template\catalog\form\renderer\fieldset\element.phtml
Find the line which reads <?php $this->checkFieldDisable() ?>
Underneath this, insert this block (edit "sku" to whatever you need):
<?php
// Disable editing of SKU field
if ($_element->name == "sku") {
$_element->setDisabled(true);
}
?>
There may be an even more elegant way of doing this, such as setting the "disabled" option somewhere in the database, but since these are system attributes I doubt it. This works!
Upvotes: 2