oro meetup #4
TRANSCRIPT
cystbearErlanger
Symfony expert
MongoDB adept
OSS doerhttps://twitter.com/1cdecoderhttps://github.com/cystbearhttp://trinity.ck.ua/
Frontend Validation
No time for REST
Validation<?php
namespace AppBundle/Entity/Author;
use Symfony\Component\Validator\Constraints as Assert;
class Author{ /** * @Assert\NotBlank() */ public $name;}
Twig Rendering{# app/Resources/views/default/new.html.twig #}{{ form_start(form) }} {{ form_errors(form) }}
{{ form_row(form.task) }} {{ form_row(form.dueDate) }}{{ form_end(form) }}
UberFrontendValidationBundle
Installationcomposer require sleepness/uber-frontend-validation-bundle
$bundles = array( new Sleepness\UberFrontendValidationBundle\SleepnessUberFrontendValidationBundle(),);
twig: form_themes: - 'SleepnessUberFrontendValidationBundle:Form:fields.html.twig'
{{ validation_init() }}
jQuery
Result<div> <label for="advert_title" class="required">Title</label> <input type="text" id="advert_title" name="advert[title]" data-message-notblank="This value should not be blank." data-constraint="NotBlank" /></div>
Result-2<div> <label for="advert_title" class="required">Title</label> <input type="url" id="advert_title" name="advert[title]" data-message-notblank="This value should not be blank." data-message-url="This value is not a valid URL." data-constraint="NotBlank Url" /></div>
Sleepness
https://github.com/Sleepness/UberFrontendValidationBundle
Q? A!