public function makeFields() { $this->reference = new CharField(['label' => Product::getAttributeName('reference')]); $this->name = new CharField(['label' => Product::getAttributeName('name')]); $this->price = new FloatField(['label' => Product::getAttributeName('price')]); $this->weight = new FloatField(['label' => Product::getAttributeName('weight')]); $this->text = new CharField(['label' => Product::getAttributeName('text')]); $this->stock = new IntegerField(['label' => Product::getAttributeName('stock')]); $this->description = new CharField(['label' => Product::getAttributeName('description')]); $this->category_id = new IntegerField(['label' => Product::getAttributeName('category_id')]); $this->category_id->setOptions(function () { $result = array('' => ''); foreach (ProductCategory::get() as $category) { $result[$category->id] = $category->fullName; } return $result; }); }