public function __construct(ObjectManager $objectManager) { parent::__construct('register'); $this->filter = new InputFilter(); $primary = new Element\Hidden('primary'); $this->add($primary); $callName = new Element\Text('callName'); $callName->setAttribute('required', true); $callName->setAttribute('placeholder', 'Call Name'); $this->add($callName); $callNameFilter = new Input('callName'); $callNameFilter->setRequired(true); $callNameFilter->getFilterChain()->attach(new AppFilter\TitleCase()); $callNameFilter->getFilterChain()->attach(new Filter\StringTrim()); $callNameFilter->getFilterChain()->attach(new Filter\StripTags()); $callNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 15))); $callNameFilter->getValidatorChain()->attach(new LocaleValidator\Alpha(array('allowWhiteSpace' => true))); $this->filter->add($callNameFilter); $regName = new Element\Text('regName'); $regName->setAttribute('placeholder', 'Registered Name'); $this->add($regName); $regNameFilter = new Input('regName'); $regNameFilter->setRequired(false); $regNameFilter->getFilterChain()->attach(new AppFilter\TitleCase()); $regNameFilter->getFilterChain()->attach(new Filter\StringTrim()); $regNameFilter->getFilterChain()->attach(new Filter\StripTags()); $regNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 50))); $regNameFilter->getValidatorChain()->attach(new Validator\Regex("/^[a-z][a-z\\'\\- ]*\$/i")); $this->filter->add($regNameFilter); $sex = new Element\Select('sex'); $sex->setAttribute('required', true); $sex->setValueOptions(array(1 => 'Male', 2 => 'Female')); $sex->setEmptyOption('Select a Sex'); $this->add($sex); $sexFilter = new Input('sex'); $sexFilter->setRequired(true); $this->filter->add($sexFilter); $breed = new AppElement\ObjectLiveSearch('breed'); $breed->setOption('object_manager', $objectManager); $breed->setOption('target_class', 'Application\\Entity\\Breed'); $breed->setOption('find_method', array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC')))); $breed->setEmptyOption('Select a Breed'); $this->add($breed); $breedFilter = new Input('breed'); $breedFilter->setRequired(true); $this->filter->add($breedFilter); $dateOfBirth = new Element\Date('dateOfBirth'); $dateOfBirth->setAttribute('required', true); $dateOfBirth->setAttribute('data-placeholder', 'Date of Birth'); // placeholder attr is invalid for date input $dateOfBirth->setAttribute('data-mask', '0000-00-00'); $dateOfBirth->setAttribute('class', 'datepicker'); $this->add($dateOfBirth); $dateOfBirthFilter = new Input('dateOfBirth'); $dateOfBirthFilter->setRequired(true); $dateOfBirthFilter->getValidatorChain()->attach(new Validator\Date()); $this->filter->add($dateOfBirthFilter); $height = new Element\Number('height'); $height->setAttribute('required', true); $height->setAttribute('placeholder', 'Height (Inches)'); $this->add($height); $heightFilter = new Input('height'); $heightFilter->setRequired(true); $heightFilter->getValidatorChain()->attach(new Validator\Between(array('min' => 6, 'max' => 30))); $this->filter->add($heightFilter); $champion = new Element\Checkbox('champion'); $champion->setLabel('Dog is a champion of record.'); $this->add($champion); $championFilter = new Input('champion'); $championFilter->setRequired(false); $this->filter->add($championFilter); $rescue = new Element\Checkbox('rescue'); $rescue->setLabel('Dog is a rescue.'); $this->add($rescue); $rescueFilter = new Input('rescue'); $rescueFilter->setRequired(false); $this->filter->add($rescueFilter); $buttons = new Form('buttons'); $buttons->setOption('twb-layout', 'inline'); $buttons->setAttribute('class', 'form-group'); $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn-primary pull-right'); $submit->setOption('glyphicon', 'circle-arrow-up'); $submit->setLabel('Register'); $buttons->add($submit); $cancel = new Element\Submit('cancel'); $cancel->setAttribute('formnovalidate', true); $cancel->setAttribute('class', 'btn-warning pull-right'); $cancel->setOption('glyphicon', 'ban-circle'); $cancel->setLabel('Cancel'); $buttons->add($cancel); $this->add($buttons); }
public function __construct(Member $memberEntity, Event $eventEntity, ObjectManager $objectManager) { parent::__construct('entry'); $this->filter = new InputFilter(); $dog = new AppElement\ObjectLiveSearch('dog'); $dog->setOption('object_manager', $objectManager); $dog->setOption('target_class', 'Application\\Entity\\Dog'); $dog->setOption('find_method', array('name' => 'findBy', 'params' => array('criteria' => array('primary' => $memberEntity->getId()), 'orderBy' => array('callName' => 'ASC')))); $dog->setEmptyOption('Select a Dog'); $this->add($dog); $dogFilter = new Input('dog'); $dogFilter->setRequired(true); $this->filter->add($dogFilter); $entryNum = 0; foreach ($eventEntity->getTrials() as $trialEntity) { $trial = new Form('trial_' . $trialEntity->getId()); $trial->setLabel($trialEntity->getDateDisplay()); $this->add($trial); foreach ($trialEntity->getTrialDivisions() as $trialDivisionEntity) { $divisionEntity = $trialDivisionEntity->getDivision(); for ($whichDivisionNum = 1; $whichDivisionNum <= $trialDivisionEntity->getNumOffered(); $whichDivisionNum++) { $entry = new Fieldset('entry_' . $entryNum++); $entry->setOption('twb-layout', 'inline'); $entry->setAttribute('data-price', trim($trialDivisionEntity->getEntryFee(), '$')); $entry->setAttribute('class', 'form-group entry-form'); $this->add($entry); $entry->filter = new InputFilter(); $this->filter->add($entry->filter); $hiddenTrial = new Element\Hidden('trial'); $hiddenTrial->setValue($trialEntity->getId()); $entry->add($hiddenTrial); $hiddenDivision = new Element\Hidden('division'); $hiddenDivision->setValue($divisionEntity->getId()); $entry->add($hiddenDivision); $whichDivision = new Element\Hidden('whichDivision'); $whichDivision->setValue($whichDivisionNum); $entry->add($whichDivision); $entered = new Element\Checkbox('entered'); $entered->setLabel($divisionEntity . ($trialDivisionEntity->getNumOffered() > 1 ? ' #' . $whichDivisionNum : '')); $entry->add($entered); $enteredFilter = new Input('entered'); $enteredFilter->setRequired(false); $entry->filter->add($enteredFilter); if (!$divisionEntity->isAllLevels()) { $level = new AppElement\ObjectLiveSearch('level'); $level->setOption('object_manager', $objectManager); $level->setOption('target_class', 'Application\\Entity\\Level'); $level->setOption('find_method', array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('rank' => 'ASC')))); $level->setEmptyOption('Select a Level'); $entry->add($level); $levelFilter = new Input('level'); $levelFilter->setRequired(false); $entry->filter->add($levelFilter); } $exhibitionOnly = new Element\Checkbox('exhibitionOnly'); $exhibitionOnly->setLabelAttributes(array('class' => 'small col-md-offset-2')); $exhibitionOnly->setLabel('For exhibition only'); $entry->add($exhibitionOnly); $exhibitionOnlyFilter = new Input('exhibitionOnly'); $exhibitionOnlyFilter->setRequired(false); $entry->filter->add($exhibitionOnlyFilter); } } } $buttons = new Form('buttons'); $buttons->setOption('twb-layout', 'inline'); $buttons->setAttribute('class', 'form-group'); $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn-event pull-right'); $submit->setOption('glyphicon', 'circle-arrow-up'); $submit->setLabel('Submit Entry'); $buttons->add($submit); $cancel = new Element\Submit('cancel'); $cancel->setAttribute('formnovalidate', true); $cancel->setAttribute('class', 'btn-warning pull-right'); $cancel->setOption('glyphicon', 'ban-circle'); $cancel->setLabel('Cancel'); $buttons->add($cancel); $this->add($buttons); }