Skip to content

Instantly share code, notes, and snippets.

@erop
Last active April 27, 2021 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erop/e37bee341deeb0d894535e78ac7da4d4 to your computer and use it in GitHub Desktop.
Save erop/e37bee341deeb0d894535e78ac7da4d4 to your computer and use it in GitHub Desktop.
DocumentField annotation
<?php
namespace App\Annotation;
use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Annotation\Target;
/**
* @Annotation
* @Target("PROPERTY")
*/
class DocumentField
{
/**
* Set <label> for the form field
* @Annotation\Required()
*/
public string $label;
/**
* Choose the correct type for HTML input
* @Annotation\Required()
* @Annotation\Enum({"text", "textarea", "date", "select", "datetime-local", "email", "tel"})
*/
public string $htmlInputType = "text";
/**
* Add default value if needed
*/
public string $defaultValue;
/**
* Here you can set a mask for future validation tasks
*/
public string $mask;
/**
* Use this element to inform frontend should the field be required or not
*/
public bool $required = true;
/**
* If you need a <select> element in a form use this property
*/
public array $values;
/**
* Setting to true will let you create a <select multiple> input
*/
public bool $multiple = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment