2013-05-13 4 views
3

클라이언트의 Magento에서 백엔드에 읽기 전용 필드를 만들고 싶습니다.Magento 백엔드 필드 만들기 ReadOnly

$installer->addAttribute("customer", "attrcode", array(
    "type"  => "varchar", 
    "backend" => "", 
    "label" => "label", 
    "input" => "text", 
    "source" => "", 
    "visible" => true, 
    "required" => false, 
    "default" => "", 
    "frontend" => "", 
    "unique"  => false, 

    )); 

는 필드를 만들고 이러한 방법으로, 그러나 그는 단지

내가하지 않는 당신에게

답변

3

한 가지 가능한 솔루션을 가지고는 페이지로드에있는 버튼을 비활성화 자바 스크립트를 사용하는 것입니다

의 js 파일을 생성하고 관리 피부/JS 디렉토리에 업로드 (disable_button.js)

추가

document.observe('dom:loaded', function(){ 
    $("target_input_id").disabled=true; 
}); 

다음 추가 또는 I 제품, 범주 및 CMS 페이지에 대한 작업 정확히 같은 확장을 개발

<?xml version="1.0"?> 
<layout version="0.1.0"> 
    <adminhtml_customer_edit> 
     <reference name="head"> 
      <action method="addItem"><type>skin_js</type><script>js/disable_button.js</script></action> 
     </reference> 
    </adminhtml_customer_edit> 
</layout> 
+0

죄송합니다. –

1

감사 읽고 ... 아니에요 : (모듈을 통해) 알고 필드를 만드는 것입니다 다음과 같이 당신이 시도하고있는 것 같아 addAttribute(), _prepareValues($attr) 메서드를 사용하면 $data에 저장되는 특정 값만 허용 할 수 있습니다.

모양의 @ 응용 프로그램/코드/코어/마법사/EAV/모델/법인/Setup.php가

public function addAttribute($entityTypeId, $code, array $attr) 
{ 
    $entityTypeId = $this->getEntityTypeId($entityTypeId); 
    $data = array_merge(
     array(
      'entity_type_id' => $entityTypeId, 
      'attribute_code' => $code 
     ), 
     $this->_prepareValues($attr); 
    ); 
    ..... 
    if ($attributeId) { 
     $this->updateAttribute($entityTypeId, $attributeId, $data, null, $sortOrder); 
    } else { 
     $this->_insertAttribute($data); 
    } 
    ....... 
} 


protected function _prepareValues($attr) 
{ 
    $data = array(
     'backend_model' => $this->_getValue($attr, 'backend'), 
     'backend_type' => $this->_getValue($attr, 'type', 'varchar'), 
     'backend_table' => $this->_getValue($attr, 'table'), 
     'frontend_model' => $this->_getValue($attr, 'frontend'), 
     'frontend_input' => $this->_getValue($attr, 'input', 'text'), 
     'frontend_label' => $this->_getValue($attr, 'label'), 
     'frontend_class' => $this->_getValue($attr, 'frontend_class'), 
     'source_model' => $this->_getValue($attr, 'source'), 
     'is_required'  => $this->_getValue($attr, 'required', 1), 
     'is_user_defined' => $this->_getValue($attr, 'user_defined', 0), 
     'default_value' => $this->_getValue($attr, 'default'), 
     'is_unique'  => $this->_getValue($attr, 'unique', 0), 
     'note'   => $this->_getValue($attr, 'note'), 
     'is_global'  => $this->_getValue($attr, 'global', 
           Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL 
          ), 
    ); 

    return $data; 
} 
1

JS 파일을 포함하는 local.xml 업데이트합니다. 몇 가지 규칙을 정의하고 읽기 전용으로 표시 할 속성을 선택해야합니다.

Magento Products Admin Read-Only

확장 URL : 확실히 당신이 무슨 뜻인지 이해하지 못했다 https://www.bubbleshop.net/magento-admin-readonly.html

관련 문제