Skip to content

Instantly share code, notes, and snippets.

@khepin
Created August 12, 2011 03:41
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save khepin/1141390 to your computer and use it in GitHub Desktop.
<?php
class HoleType extends AbstractType
{
/**
* Used to populate from the constructor
* @var Hole
*/
private $hole = null;
public function __construct(Hole $hole = null) {
$this->hole = $hole;
}
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('number', new HiddenType())
->add('par', 'choice', array(
// hardcoded because seriously the rules of golf have not changed that much over a few centuries ;-)
'choices' => array(
'3' => '3',
'4' => '4',
'5' => '5',
),
// expanded + NOT multiple = will display as radio buttons
'expanded' => true,
'multiple' => false,
))
;
if (!is_null($this->hole)){
$builder->setData($this->hole);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment