Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?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