<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\FormFieldsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
#[ORM\Entity(repositoryClass: FormFieldsRepository::class)]
#[ApiResource]
#[ApiFilter(SearchFilter::class, properties: [
'form.id' => 'exact',
])]
class FormFields
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
private ?string $label = null;
#[ORM\Column(length: 255)]
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
private ?string $type = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
private ?string $defaultValue = null;
#[ORM\ManyToOne(inversedBy: 'formFields')]
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
private ?Form $form = null;
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\OneToMany(mappedBy: 'formField', targetEntity: FormAnswerFields::class)]
private Collection $formAnswerFields;
#[Groups(['form:read', 'form:write', 'formAnswer:read', 'formAnswer:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $selectedLabelInput = null;
public function __construct()
{
$this->formAnswerFields = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getDefaultValue(): ?string
{
return $this->defaultValue;
}
public function setDefaultValue(?string $defaultValue): self
{
$this->defaultValue = $defaultValue;
return $this;
}
public function getForm(): ?Form
{
return $this->form;
}
public function setForm(?Form $form): self
{
$this->form = $form;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, FormAnswerFields>
*/
public function getFormAnswerFields(): Collection
{
return $this->formAnswerFields;
}
public function addFormAnswerField(FormAnswerFields $formAnswerField): self
{
if (!$this->formAnswerFields->contains($formAnswerField)) {
$this->formAnswerFields->add($formAnswerField);
$formAnswerField->setFormField($this);
}
return $this;
}
public function removeFormAnswerField(FormAnswerFields $formAnswerField): self
{
if ($this->formAnswerFields->removeElement($formAnswerField)) {
// set the owning side to null (unless already changed)
if ($formAnswerField->getFormField() === $this) {
$formAnswerField->setFormField(null);
}
}
return $this;
}
public function getSelectedLabelInput(): ?string
{
return $this->selectedLabelInput;
}
public function setSelectedLabelInput(?string $selectedLabelInput): self
{
$this->selectedLabelInput = $selectedLabelInput;
return $this;
}
}