adding description textarea field

This commit is contained in:
Mathieu Jaumotte 2021-02-23 15:42:01 +01:00
parent 2c18b10aa0
commit ecafda9cfd
4 changed files with 83 additions and 5 deletions

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210220173846 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE beer ADD description TEXT DEFAULT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE beer DROP description');
}
}

View File

@ -26,33 +26,73 @@ class Beer
* @ORM\Column(type="float", nullable=true)
*/
private $alcool;
/**
* @ORM\Column(type="text", length=2048, nullable=true)
*/
private $description;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return null|string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return Beer
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return float|null
*/
public function getAlcool(): ?float
{
return $this->alcool;
}
/**
* @param float|null $alcool
* @return Beer
*/
public function setAlcool(?float $alcool): self
{
$this->alcool = $alcool;
return $this;
}
/**
* @return mixed
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param mixed $description
* @return Beer
*/
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
}

View File

@ -3,6 +3,7 @@
namespace App\Form;
use App\Entity\Beer;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PercentType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@ -19,6 +20,7 @@ class BeerType extends AbstractType
'scale' => 1,
'type' => 'fractional',
])
->add('description')
;
}

View File

@ -21,6 +21,10 @@
<th scope="row">{{'Alcool'}}</th>
<td>{{ beer.alcool|format_percent_number({rounding_mode: 'floor', fraction_digit: 1}) }}</td>
</tr>
<tr>
<th scope="row">{{'Description'}}</th>
<td>{{ beer.description }}</td>
</tr>
</tbody>
</table>