Created
July 17, 2012 21:46
-
-
Save chrisjlee/3132326 to your computer and use it in GitHub Desktop.
example form class in Silex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//somewhere in the controller | |
$form = $app["form.factory"]->create(new SzovegType()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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