Added some basic part edit and create forms.

This commit is contained in:
Jan Böhmer 2019-03-13 13:23:12 +01:00
parent 44c482caf2
commit cc1badb853
15 changed files with 253 additions and 95 deletions

View file

@ -2,6 +2,7 @@ twig:
default_path: '%kernel.project_dir%/templates'
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes: ['bootstrap_4_horizontal_layout.html.twig']
globals:
partdb_title: '%partdb_title%'

View file

@ -33,9 +33,14 @@
namespace App\Controller;
use App\Entity\Category;
use App\Entity\Part;
use App\Form\PartType;
use App\Services\AttachmentFilenameService;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class PartController extends AbstractController
@ -58,4 +63,59 @@ class PartController extends AbstractController
);
}
/**
* @Route("/part/{id}/edit", name="part_edit", requirements={"id"="\d+"})
*
* @param Part $part
* @return \Symfony\Component\HttpFoundation\Response
*/
public function edit(Part $part, Request $request)
{
$form = $this->createForm(PartType::class, $part);
$form->handleRequest($request);
return $this->render('edit_part_info.html.twig',
[
"part" => $part,
"form" => $form->createView()
]);
}
/**
* @Route("/parts/new", name="part_new")
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function new(Request $request, EntityManagerInterface $em)
{
$new_part = new Part();
$category = $em->find(Category::class, 1);
$new_part->setCategory($category);
$this->addFlash('success', 'Article Created!');
$form = $this->createForm(PartType::class, $new_part);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
/** @var Article $article */
//$part = $form->getData();
$em->persist($new_part);
$em->flush();
$this->addFlash('success', 'Article Created! Knowledge is power!');
return $this->redirectToRoute('part_edit',['id' => $new_part->getID()]);
}
return $this->render('edit_part_info.html.twig',
[
"part" => $new_part,
"form" => $form->createView()
]);
}
}

View file

@ -68,8 +68,8 @@ class Attachment extends NamedDBElement
/**
* Check if this attachement is a picture (analyse the file's extension)
*
* @return boolean @li true if the file extension is a picture extension
* @li otherwise false
* @return boolean * true if the file extension is a picture extension
* * otherwise false
*/
public function isPicture() : bool
{

View file

@ -63,8 +63,8 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
/**
* Get all attachements of this element / Get the element's attachements with a specific type
*
* @param integer $type_id @li if NULL, all attachements of this element will be returned
* @li if this is a number > 0, only attachements with this type ID will be returned
* @param integer $type_id * if NULL, all attachements of this element will be returned
* * if this is a number > 0, only attachements with this type ID will be returned
* @param boolean $only_table_attachements if true, only attachements with "show_in_table == true"
*
* @return Attachment[] the attachements as a one-dimensional array of Attachement objects

View file

@ -128,8 +128,8 @@ abstract class Company extends StructuralDBElement
/**
* Get the link to the website of an article
*
* @param string $partnr @li NULL for returning the URL with a placeholder for the part number
* @li or the part number for returning the direct URL to the article
* @param string $partnr * NULL for returning the URL with a placeholder for the part number
* * or the part number for returning the direct URL to the article
*
* @return string the link to the article
*/

View file

@ -90,7 +90,7 @@ class Footprint extends PartsContainingDBElement
/**
* Get the filename of the picture (absolute path from filesystem root)
* @return string the saved filename in the DB
* @li an empty string if there is no picture
* * an empty string if there is no picture
*/
public function getFilename() : string
{
@ -103,8 +103,8 @@ class Footprint extends PartsContainingDBElement
* @param bool $absolute If set to true, then the absolute filename (from system root) is returned.
* If set to false, then the path relative to Part-DB folder is returned.
*
* @return string @li the absolute path to the model (from filesystem root), as a UNIX path (with slashes)
* @li an empty string if there is no model
* @return string * the absolute path to the model (from filesystem root), as a UNIX path (with slashes)
* * an empty string if there is no model
*/
public function get3dFilename(bool $absolute = true) : string
{
@ -125,8 +125,8 @@ class Footprint extends PartsContainingDBElement
*
* An empty filename is a valid filename.
*
* @return boolean @li true if file exists or filename is empty
* @li false if there is no file with this filename
* @return boolean * true if file exists or filename is empty
* * false if there is no file with this filename
*/
public function isFilenameValid() : bool
{
@ -145,8 +145,8 @@ class Footprint extends PartsContainingDBElement
*
* An empty filename is a valid filename.
*
* @return boolean @li true if file exists or filename is empty
* @li false if there is no file with this filename
* @return boolean * true if file exists or filename is empty
* * false if there is no file with this filename
*/
public function is3dFilenameValid() : bool
{
@ -179,8 +179,8 @@ class Footprint extends PartsContainingDBElement
* It's not really a Problem if there is no such file...
* (For this purpose we have the method Footprint::get_broken_filename_footprints())
*
* @param string $new_filename @li the new filename (absolute path from filesystem root, as a UNIX path [only slashes!] !! )
* @li see also lib.functions.php::to_unix_path()
* @param string $new_filename * the new filename (absolute path from filesystem root, as a UNIX path [only slashes!] !! )
* * see also lib.functions.php::to_unix_path()
*
* It's really important that you pass the whole (UNIX) path from filesystem root!
* If the file is located in the base directory of Part-DB, the base path

View file

@ -25,6 +25,8 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* All subclasses of this class have an attribute "name".
*
@ -36,8 +38,10 @@ abstract class NamedDBElement extends DBElement
/**
* @var string The name of this element.
* @ORM\Column(type="string")
* @Assert\NotBlank()
*
*/
protected $name;
protected $name = "";
/**
* @var \DateTime The date when this element was modified the last time.
@ -64,8 +68,10 @@ abstract class NamedDBElement extends DBElement
*/
public function getName() : string
{
/*
//Strip HTML from Name, so no XSS injection is possible.
return strip_tags($this->name);
return strip_tags($this->name); */
return $this->name;
}
/**

View file

@ -136,8 +136,8 @@ class Orderdetail extends DBElement
* "Orderdetails is obsolete" means that the part with that supplier-part-nr
* is no longer available from the supplier of that orderdetails.
*
* @return boolean @li true if this part is obsolete at that supplier
* @li false if this part isn't obsolete at that supplier
* @return boolean * true if this part is obsolete at that supplier
* * false if this part isn't obsolete at that supplier
*/
public function getObsolete() : bool
{
@ -177,11 +177,11 @@ class Orderdetail extends DBElement
/**
* Get the price for a specific quantity
*
* @param boolean $as_money_string @li if true, this method returns a money string incl. currency
* @li if false, this method returns the price as float
* @param boolean $as_money_string * if true, this method returns a money string incl. currency
* * if false, this method returns the price as float
* @param integer $quantity this is the quantity to choose the correct pricedetails
* @param integer|NULL $multiplier @li This is the multiplier which will be applied to every single price
* @li If you pass NULL, the number from $quantity will be used
* @param integer|NULL $multiplier * This is the multiplier which will be applied to every single price
* * If you pass NULL, the number from $quantity will be used
*
* @return float|null|string float: the price as a float number (if "$as_money_string == false")
* * null: if there are no prices and "$as_money_string == false"

View file

@ -35,7 +35,9 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Webmozart\Assert\Assert;
//use Webmozart\Assert\Assert;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Part
@ -108,55 +110,57 @@ class Part extends AttachmentContainingDBElement
* @var string
* @ORM\Column(type="string")
*/
protected $description;
protected $description = "";
/**
* @var int
* @ORM\Column(type="integer")
* @Assert\GreaterThanOrEqual(0)
*/
protected $instock;
protected $instock = 0;
/**
* @var int
* @ORM\Column(type="integer")
* @Assert\GreaterThanOrEqual(0)
*/
protected $mininstock;
protected $mininstock = 0;
/**
* @var string
* @ORM\Column(type="string")
*/
protected $comment;
protected $comment = "";
/**
* @var bool
* @ORM\Column(type="boolean")
*/
protected $visible;
protected $visible = true;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
protected $favorite;
protected $favorite = false;
/**
* @var int
* @ORM\Column(type="integer")
*/
protected $order_quantity;
protected $order_quantity = 0;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
protected $manual_order;
protected $manual_order = false;
/**
* @var string
* @ORM\Column(type="string")
*/
protected $manufacturer_product_url;
protected $manufacturer_product_url = "";
/**
@ -305,8 +309,8 @@ class Part extends AttachmentContainingDBElement
/**
* Get the minimum quantity which should be ordered
*
* @param boolean $with_devices @li if true, all parts from devices which are marked as "to order" will be included in the calculation
* @li if false, only max(mininstock - instock, 0) will be returned
* @param boolean $with_devices * if true, all parts from devices which are marked as "to order" will be included in the calculation
* * if false, only max(mininstock - instock, 0) will be returned
*
* @return integer the minimum order quantity
* @throws Exception
@ -455,9 +459,9 @@ class Part extends AttachmentContainingDBElement
*
* @param boolean $hide_obsolete If true, obsolete orderdetails will NOT be returned
*
* @return Orderdetails[] @li all orderdetails as a one-dimensional array of Orderdetails objects
* @return Orderdetails[] * all orderdetails as a one-dimensional array of Orderdetails objects
* (empty array if there are no ones)
* @li the array is sorted by the suppliers names / minimum order quantity
* * the array is sorted by the suppliers names / minimum order quantity
*
* @throws Exception if there was an error
*/
@ -479,9 +483,9 @@ class Part extends AttachmentContainingDBElement
/**
* Get all devices which uses this part
*
* @return Device[] @li all devices which uses this part as a one-dimensional array of Device objects
* @return Device[] * all devices which uses this part as a one-dimensional array of Device objects
* (empty array if there are no ones)
* @li the array is sorted by the devices names
* * the array is sorted by the devices names
*
* @throws Exception if there was an error
*/
@ -496,14 +500,14 @@ class Part extends AttachmentContainingDBElement
* This method simply gets the suppliers of the orderdetails and prepare them.\n
* You can get the suppliers as an array or as a string with individual delimeter.
*
* @param boolean $object_array @li if true, this method returns an array of Supplier objects
* @li if false, this method returns an array of strings
* @param string|NULL $delimeter @li if this is a string and "$object_array == false",
* @param boolean $object_array * if true, this method returns an array of Supplier objects
* * if false, this method returns an array of strings
* @param string|NULL $delimeter * if this is a string and "$object_array == false",
* this method returns a string with all
* supplier names, delimeted by "$delimeter"
* @param boolean $full_paths @li if true and "$object_array = false", the returned
* @param boolean $full_paths * if true and "$object_array = false", the returned
* suppliernames are full paths (path + name)
* @li if true and "$object_array = false", the returned
* * if true and "$object_array = false", the returned
* suppliernames are only the names (without path)
* @param boolean $hide_obsolete If true, suppliers from obsolete orderdetails will NOT be returned
*
@ -552,8 +556,8 @@ class Part extends AttachmentContainingDBElement
* This method simply gets the suppliers-part-Nrs of the orderdetails and prepare them.\n
* You can get the numbers as an array or as a string with individual delimeter.
*
* @param string|NULL $delimeter @li if this is a string, this method returns a delimeted string
* @li otherwise, this method returns an array of strings
* @param string|NULL $delimeter * if this is a string, this method returns a delimeted string
* * otherwise, this method returns an array of strings
* @param boolean $hide_obsolete If true, supplierpartnrs from obsolete orderdetails will NOT be returned
*
* @return array all supplierpartnrs as an array of strings (if "$delimeter == NULL")
@ -582,13 +586,13 @@ class Part extends AttachmentContainingDBElement
* This method simply gets the prices of the orderdetails and prepare them.\n
* In the returned array/string there is a price for every supplier.
*
* @param boolean $float_array @li if true, the returned array is an array of floats
* @li if false, the returned array is an array of strings
* @param boolean $float_array * if true, the returned array is an array of floats
* * if false, the returned array is an array of strings
* @param string|NULL $delimeter if this is a string, this method returns a delimeted string
* instead of an array.
* @param integer $quantity this is the quantity to choose the correct priceinformation
* @param integer|NULL $multiplier @li This is the multiplier which will be applied to every single price
* @li If you pass NULL, the number from $quantity will be used
* @param integer|NULL $multiplier * This is the multiplier which will be applied to every single price
* * If you pass NULL, the number from $quantity will be used
* @param boolean $hide_obsolete If true, prices from obsolete orderdetails will NOT be returned
*
* @return array all prices as an array of floats (if "$delimeter == NULL" & "$float_array == true")
@ -622,12 +626,12 @@ class Part extends AttachmentContainingDBElement
* With the $multiplier you're able to multiply the price before it will be returned.
* This is useful if you want to have the price as a string with currency, but multiplied with a factor.
*
* @param boolean $as_money_string @li if true, the retruned value will be a string incl. currency,
* @param boolean $as_money_string * if true, the retruned value will be a string incl. currency,
* ready to print it out. See float_to_money_string().
* @li if false, the returned value is a float
* * if false, the returned value is a float
* @param integer $quantity this is the quantity to choose the correct priceinformations
* @param integer|NULL $multiplier @li This is the multiplier which will be applied to every single price
* @li If you pass NULL, the number from $quantity will be used
* @param integer|NULL $multiplier * This is the multiplier which will be applied to every single price
* * If you pass NULL, the number from $quantity will be used
*
* @return float price (if "$as_money_string == false")
* @return NULL if there are no prices for this part and "$as_money_string == false"
@ -662,9 +666,9 @@ class Part extends AttachmentContainingDBElement
/**
* Get the filename of the master picture (absolute path from filesystem root)
*
* @param boolean $use_footprint_filename @li if true, and this part has no picture, this method
* @param boolean $use_footprint_filename * if true, and this part has no picture, this method
* will return the filename of its footprint (if available)
* @li if false, and this part has no picture,
* * if false, and this part has no picture,
* this method will return NULL
*
* @return string the whole path + filename from filesystem root as a UNIX path (with slashes)
@ -780,7 +784,7 @@ class Part extends AttachmentContainingDBElement
*
* @return self
*/
public function setDescription(string $new_description) : self
public function setDescription(?string $new_description) : self
{
$this->description = $new_description;
return $this;
@ -795,7 +799,7 @@ class Part extends AttachmentContainingDBElement
*/
public function setInstock(int $new_instock, $comment = null) : self
{
Assert::natural($new_instock, 'New instock must be positive. Got: %s');
//Assert::natural($new_instock, 'New instock must be positive. Got: %s');
$old_instock = (int) $this->getInstock();
$this->instock = $new_instock;
@ -844,8 +848,8 @@ class Part extends AttachmentContainingDBElement
*/
public function withdrawalParts(int $count, $comment = null) : self
{
Assert::greaterThan($count,0, 'Count of withdrawn parts must be greater 0! Got %s!');
Assert::greaterThan($count, $this->instock, 'You can not withdraw more parts, than there are existing!');
//Assert::greaterThan($count,0, 'Count of withdrawn parts must be greater 0! Got %s!');
//Assert::greaterThan($count, $this->instock, 'You can not withdraw more parts, than there are existing!');
$old_instock = $this->getInstock();
$new_instock = $old_instock - $count;
@ -876,7 +880,7 @@ class Part extends AttachmentContainingDBElement
*/
public function addParts(int $count, string $comment = null) : self
{
Assert::greaterThan($count, 0, 'Count of added parts must be greater zero! Got %s.');
//Assert::greaterThan($count, 0, 'Count of added parts must be greater zero! Got %s.');
//TODO
@ -908,7 +912,7 @@ class Part extends AttachmentContainingDBElement
*/
public function setMinInstock(int $new_mininstock) : self
{
Assert::natural($new_mininstock, 'The new minimum instock value must be positive! Got %s.');
//Assert::natural($new_mininstock, 'The new minimum instock value must be positive! Got %s.');
$this->mininstock = $new_mininstock;
return $this;
@ -933,9 +937,9 @@ class Part extends AttachmentContainingDBElement
*
* @param boolean $new_manual_order the new "manual_order" attribute
* @param integer $new_order_quantity the new order quantity
* @param integer|NULL $new_order_orderdetails_id @li the ID of the new order orderdetails
* @li or Zero for "no order orderdetails"
* @li or NULL for automatic order orderdetails
* @param integer|NULL $new_order_orderdetails_id * the ID of the new order orderdetails
* * or Zero for "no order orderdetails"
* * or NULL for automatic order orderdetails
* (if the part has exactly one orderdetails,
* set this orderdetails as order orderdetails.
* Otherwise, set "no order orderdetails")
@ -944,7 +948,7 @@ class Part extends AttachmentContainingDBElement
*/
public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, $new_order_orderdetails_id = null) : self
{
Assert::greaterThan($new_order_quantity, 0, 'The new order quantity must be greater zero. Got %s!');
//Assert::greaterThan($new_order_quantity, 0, 'The new order quantity must be greater zero. Got %s!');
$this->manual_order = $new_manual_order;
@ -959,8 +963,8 @@ class Part extends AttachmentContainingDBElement
/**
* Set the ID of the order orderdetails
*
* @param integer|NULL $new_order_orderdetails_id @li the new order orderdetails ID
* @li Or, to remove the orderdetails, pass a NULL
* @param integer|NULL $new_order_orderdetails_id * the new order orderdetails ID
* * Or, to remove the orderdetails, pass a NULL
*
* @return self
*/
@ -981,7 +985,7 @@ class Part extends AttachmentContainingDBElement
*/
public function setOrderQuantity(int $new_order_quantity) : self
{
Assert::greaterThan($new_order_quantity,0, 'The new order quantity must be greater zero. Got %s!');
//Assert::greaterThan($new_order_quantity,0, 'The new order quantity must be greater zero. Got %s!');
$this->order_quantity = $new_order_quantity;
@ -996,15 +1000,12 @@ class Part extends AttachmentContainingDBElement
*
* @param integer $new_category_id the ID of the category
*
* @throws Exception if the new category ID is not valid
* @throws Exception if there was an error
*
* @return self
*/
public function setCategoryID(int $new_category_id) : self
public function setCategory(Category $category) : self
{
//TODO
throw new \Exception("Not implemented yet!");
$this->category = $category;
return $this;
}
@ -1012,8 +1013,8 @@ class Part extends AttachmentContainingDBElement
/**
* Set the footprint ID
*
* @param integer|NULL $new_footprint_id @li the ID of the footprint
* @li NULL means "no footprint"
* @param integer|NULL $new_footprint_id * the ID of the footprint
* * NULL means "no footprint"
*
* @throws Exception if the new footprint ID is not valid
* @throws Exception if there was an error
@ -1029,8 +1030,8 @@ class Part extends AttachmentContainingDBElement
/**
* Set the storelocation ID
*
* @param integer|NULL $new_storelocation_id @li the ID of the storelocation
* @li NULL means "no storelocation"
* @param integer|NULL $new_storelocation_id * the ID of the storelocation
* * NULL means "no storelocation"
*
* @throws Exception if the new storelocation ID is not valid
* @throws Exception if there was an error
@ -1046,8 +1047,8 @@ class Part extends AttachmentContainingDBElement
/**
* Set the manufacturer ID
*
* @param integer|NULL $new_manufacturer_id @li the ID of the manufacturer
* @li NULL means "no manufacturer"
* @param integer|NULL $new_manufacturer_id * the ID of the manufacturer
* * NULL means "no manufacturer"
*
* @throws Exception if the new manufacturer ID is not valid
* @throws Exception if there was an error
@ -1089,8 +1090,8 @@ class Part extends AttachmentContainingDBElement
/**
* Set the ID of the master picture Attachement
*
* @param integer|NULL $new_master_picture_attachement_id @li the ID of the Attachement object of the master picture
* @li NULL means "no master picture"
* @param integer|NULL $new_master_picture_attachement_id * the ID of the Attachement object of the master picture
* * NULL means "no master picture"
*
* @throws Exception if the new ID is not valid
* @throws Exception if there was an error

View file

@ -103,8 +103,8 @@ class Pricedetail extends DBElement
/**
* Get the price
*
* @param boolean $as_money_string @li if true, this method returns a money string incl. currency
* @li if false, this method returns the price as float
* @param boolean $as_money_string * if true, this method returns a money string incl. currency
* * if false, this method returns the price as float
* @param integer $multiplier The returned price (float or string) will be multiplied
* with this multiplier.
*
@ -168,8 +168,8 @@ class Pricedetail extends DBElement
*
* @param float $new_price the new price as a float number
*
* @li This is the price for "price_related_quantity" parts!!
* @li Example: if "price_related_quantity" is '10',
* * This is the price for "price_related_quantity" parts!!
* * Example: if "price_related_quantity" is '10',
* you have to set here the price for 10 parts!
*
* @return self

View file

@ -78,8 +78,8 @@ class Storelocation extends PartsContainingDBElement
* "is_full == true" means that there is no more space in this storelocation.
* This attribute is only for information, it has no effect.
*
* @return boolean @li true if the storelocation is full
* @li false if the storelocation isn't full
* @return boolean * true if the storelocation is full
* * false if the storelocation isn't full
*/
public function getIsFull() : bool
{
@ -98,8 +98,8 @@ class Storelocation extends PartsContainingDBElement
* "is_full" = true means that there is no more space in this storelocation.
* This attribute is only for information, it has no effect.
*
* @param boolean $new_is_full @li true means that the storelocation is full
* @li false means that the storelocation isn't full
* @param boolean $new_is_full * true means that the storelocation is full
* * false means that the storelocation isn't full
*
* @throws Exception if there was an error
*/

View file

@ -122,9 +122,9 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* @brief Get the parent-ID
*
* @retval integer @li the ID of the parent element
* @li NULL means, the parent is the root node
* @li the parent ID of the root node is -1
* @retval integer * the ID of the parent element
* * NULL means, the parent is the root node
* * the parent ID of the root node is -1
*/
public function getParentID() : int
{
@ -235,8 +235,8 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* Change the parent ID of this element
*
* @param integer|null $new_parent_id @li the ID of the new parent element
* @li NULL if the parent should be the root node
* @param integer|null $new_parent_id * the ID of the new parent element
* * NULL if the parent should be the root node
*/
public function setParentID($new_parent_id) : self
{

55
src/Form/PartType.php Normal file
View file

@ -0,0 +1,55 @@
<?php
/**
*
* part-db version 0.1
* Copyright (C) 2005 Christoph Lechner
* http://www.cl-projects.de/
*
* part-db version 0.2+
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
* http://code.google.com/p/part-db/
*
* Part-DB Version 0.4+
* Copyright (C) 2016 - 2019 Jan Böhmer
* https://github.com/jbtronics
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Form;
use phpDocumentor\Reflection\Types\Integer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\ResetType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class PartType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class)
->add('description', TextType::class, ['required'=>false])
->add('instock', IntegerType::class)
->add('mininstock', IntegerType::class)
->add('save', SubmitType::class, ['label' => 'part.edit.save'])
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
}
}

View file

@ -0,0 +1,19 @@
{% extends "main_card.html.twig" %}
{% block title %}
{% trans with {'%name%': part.name} %}part.edit.title{% endtrans %}
{% endblock %}
{% block card_title %}
<i class="far fa-edit fa-fw" aria-hidden="true"></i>
{% trans with {'%name%': part.name} %}part.edit.card_title{% endtrans %}
<div class="float-right">
{% trans %}id.label{% endtrans %}: {{ part.id }}
</div>
{% endblock %}
{% block card_content %}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
{% endblock %}

View file

@ -0,0 +1,16 @@
{% extends "base.html.twig" %}
{% block content %}
<div class="card border-primary">
{% block card_header %}
<div class="card-header bg-primary text-white">
{% block card_title %}{% endblock %}
</div>
{% endblock %}
{% block card_body %}
<div class="card-body">
{% block card_content %}{% endblock %}
</div>
{% endblock %}
</div>
{% endblock %}