Magento and unsetting a custom boolean attribute

Posted by Spongeboy on Stack Overflow See other posts from Stack Overflow or by Spongeboy
Published on 2009-12-09T05:44:45Z Indexed on 2011/01/14 23:53 UTC
Read the original article Hit count: 180

Filed under:
|
|
|
|

Hi,

I've added an attribute to a customer address entity. Attribute setup code is as follows-

'entity_type_id'=>$customer_address_type_id,
'attribute_code'=>'signature_required',
'backend_type'=>'int',
'frontend_input'=>'boolean',
'frontend_label' => 'Signature required',
'is_global' => '1',
'is_visible' => '1',
'is_required' => '0',
'is_user_defined' => '0',

I have then -

  • added attribute to model\entity\setup.php
  • added a HTML field on the edit form

I am now getting the attribute saved to the database when the checkbox is checked. However, it is not being unset when checkbox is unchecked (I'm guessing due to checkbox input not being 'post'-ed if unchecked.

What is the best way to uncheck this? Should I add a default value of 0? Or unset/delete the attribute before save in the controller? Should I add get/set methods to the model?

© Stack Overflow or respective owner

Related posts about custom

Related posts about magento