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 | |
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