views:

316

answers:

1

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?

+1  A: 

In the end, I overrode the setData method in my custom model.

I did find some good resources on trying to override/overload (both terms are common) controllers/routers.

Also of note -

'frontend_input'=>'boolean',

should be

'frontend_input'=>'checkbox',
Spongeboy