/**
  * Initialize the products form
  *
  * @param mixed $entity
  * @param array $options
  */
 public function initialize($entity = null, array $options = null)
 {
     if (!isset($options['edit'])) {
         $element = new Text("id");
         $this->add($element->setLabel("Id"));
     } else {
         $this->add(new Hidden("id"));
     }
     $name = new Text("name");
     $name->setLabel("Name");
     $name->setFilters(['striptags', 'string']);
     $name->addValidators([new PresenceOf(['message' => 'Name is required'])]);
     $this->add($name);
     $type = new Select('product_types_id', ProductTypes::find(), ['using' => ['id', 'name'], 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '']);
     $type->setLabel('Type');
     $this->add($type);
     $price = new Text("price");
     $price->setLabel("Price");
     $price->setFilters(['float']);
     $price->addValidators([new PresenceOf(['message' => 'Price is required']), new Numericality(['message' => 'Price is required'])]);
     $this->add($price);
 }
 /**
  * Deletes a producttypes
  *
  * @param string $id
  */
 public function deleteAction($id)
 {
     $productTypes = ProductTypes::findFirstById($id);
     if (!$productTypes) {
         $this->flash->error("Product types was not found");
         return $this->forward("producttypes/index");
     }
     if (!$productTypes->delete()) {
         foreach ($productTypes->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->forward("producttypes/search");
     }
     $this->flash->success("product types was deleted");
     return $this->forward("producttypes/index");
 }