Professional Documents
Culture Documents
Symfony
Symfony
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
trodou hakka
<script src="{{asset('vendor/tinymce/tinymce.min.js')}}"></script>
<script src="{{asset('vendor/php-email-form/validate.js')}}"></script>
w tzid {% block body %}
{% endblock %}
hedha lkoll bech taamlou martin khater aandek 2 templates wahda front office mtaa l
user w wahda backoffice mtaa ltemplate
- lback office heya /templates/base.html.twig
- lfront office heya /templates/frontTemplate.html.twig
-----Controle de saisie
temchi lel entité eli bech taamel feha controle de saisie thot l ligne hedhi
melowel
use Symfony\Component\Validator\Constraints as Assert;
mbaaed tzid les controle de saisie fouk koll attribut thheb taamel aalih kima l
example hedha
/**
* @var string
*
* @ORM\Column(name="message_rep", type="string", length=255)
*/
private $messageRep;
badalneh radina
/**
* @var string
*
* @ORM\Column(name="message_rep", type="string", length=255)
* @Assert\NotBlank
* @Assert\Length(
* min = 5,
* max = 50,
* minMessage = "Your message must be at least {{ limit }} characters
long",
* maxMessage = "Your message cannot be longer than {{ limit }}
characters"
* )
*/
private $messageRep;
mbaaed temchi /teamplates/esm l entite / _form.html.twig
thhot l ligne hedhi
{{form_start(form,{'attr':{'class':'form-
horizontal',novalidate:'novalidate'}})}} // novalidate:'novalidate' hedheya lezma
bech ywwali yaamel les controle de saisie
fi blaset hedhi ( li par defaut )
{{ form_start(form) }}
w thhot hedhom
<tr>
<td>{{form_label(form.message,"Message")}}</td> ( hedhi l
message li bjnab l input ) form.message edheka esm l attribut w l "Message" chnowa
bch ikounn affiché
<td>{{form_widget(form.message,{ 'attr': {'class': 'form-control my-2'} })}}</td>
(hedhi l input bidou ) w hedhi { 'attr': {'class': 'form-control my-2'} } juste
zina bech twali l input adheka tzidou class css form-control li heya tzayen w kahaw
<td>{{form_errors(form.message)}}</td> // bech y'affichi l
message d'erreur ghadi
</tr>