86 lines
2.2 KiB
PHP
86 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Core\Form\FileManager\FilePickerType;
|
|
use App\Core\Form\Type\CollectionType as MurphCollectionType;
|
|
use App\Entity\StlMesh;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
|
|
|
class StlMeshType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder->add(
|
|
'label',
|
|
TextType::class,
|
|
[
|
|
'label' => 'Libellé',
|
|
'required' => true,
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new NotBlank(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'description',
|
|
TextareaType::class,
|
|
[
|
|
'label' => 'Description',
|
|
'required' => false,
|
|
'attr' => [
|
|
'data-simplemde' => '',
|
|
'rows' => 5,
|
|
],
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'files',
|
|
MurphCollectionType::class,
|
|
[
|
|
'label' => 'Fichiers STL',
|
|
'entry_type' => StlFileType::class,
|
|
'by_reference' => false,
|
|
'allow_add' => true,
|
|
'allow_delete' => true,
|
|
'prototype' => true,
|
|
'collection_name' => 'stlfiles',
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'preview',
|
|
FilePickerType::class,
|
|
[
|
|
'label' => 'Image d\'aperçu',
|
|
'required' => false,
|
|
'attr' => [
|
|
],
|
|
'row_attr' => [
|
|
'class' => 'col-md-6',
|
|
],
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => StlMesh::class,
|
|
]);
|
|
}
|
|
}
|