Skip to content

Instantly share code, notes, and snippets.

@edwinschaap
Created December 11, 2012 11:07
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 edwinschaap/4257820 to your computer and use it in GitHub Desktop.
Save edwinschaap/4257820 to your computer and use it in GitHub Desktop.
example form class in Silex
<?php
//somewhere in the controller
$form = $app["form.factory"]->create(new SzovegType());
<?php
namespace Insolis\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class SzovegType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add("content", "textarea", array(
"label" => "Szöveg",
"constraints" => array(
new Assert\NotBlank(),
),
));
}
public function getName()
{
return "szoveg";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment