LemonStand Documentation

shop:onExtendCategoryForm event

This event allows to add new fields to the Create/Edit Category form in the Administration Area. Usually this event is used together with the shop:onExtendCategoryForm event. The event handler should accept two parameters - the category object (Shop_Category) and the form execution context string. To add new fields to the category form, please call the add_form_field() method of the category object. Please read the Extending existing models article to learn more about extending the category model.

Example of the event handler:

public function subscribeEvents()
{
   Backend::$events->addEvent('shop:onExtendCategoryModel', $this, 'extend_category_model');
   Backend::$events->addEvent('shop:onExtendCategoryForm', $this, 'extend_category_form');
}

public function extend_category_model($category, $context)
{
   $category->define_column('x_extra_description', 'Extra description');
}

public function extend_category_form($category, $context)
{
   $category->add_form_field('x_extra_description')->tab('Category');
}

Next: shop:onGetCategoryFieldOptions event
Previous: shop:onExtendCategoryModel event
Return to Handling LemonStand events