/** * Gets the field definitions for the form. * * @since 0.1 * * @param Contest $contest * @param integer|false $challengeId * @return array */ protected function getFormFields(Contest $contest, $challengeId) { $fields = array(); $user = $this->getUser(); $fields['contest-id'] = array('type' => 'hidden', 'default' => $contest->getId(), 'id' => 'contest-id'); $fields['contestant-realname'] = array('type' => 'text', 'default' => $user->getRealName(), 'label-message' => 'contest-signup-realname', 'required' => true, 'validation-callback' => array(__CLASS__, 'validateNameField')); $fields['contestant-email'] = array('type' => 'text', 'default' => $user->getEmail(), 'label-message' => 'contest-signup-email', 'required' => true, 'validation-callback' => array(__CLASS__, 'validateEmailField')); $fields['contestant-country'] = array('type' => 'select', 'label-message' => 'contest-signup-country', 'required' => true, 'options' => ContestContestant::getCountriesForInput(true), 'validation-callback' => array(__CLASS__, 'validateCountryField')); $fields['contestant-challengeid'] = array('type' => 'radio', 'label-message' => 'contest-signup-challenge', 'options' => $this->getChallengesList($contest), 'required' => true, 'validation-callback' => array(__CLASS__, 'validateChallengeField')); if ($challengeId !== false) { $fields['contestant-challengeid']['default'] = $challengeId; } $fields['contestant-volunteer'] = array('type' => 'check', 'default' => '0', 'label-message' => 'contest-signup-volunteer'); $fields['contestant-wmf'] = array('type' => 'check', 'default' => '0', 'label-message' => 'contest-signup-wmf'); $fields['contestant-readrules'] = array('type' => 'check', 'default' => '0', 'label-message' => array('contest-signup-readrules', $contest->getField('rules_page')), 'validation-callback' => array(__CLASS__, 'validateRulesField'), 'id' => 'contest-rules', 'data-foo' => 'bar'); return $fields; }
/** * Gets the field definitions for the form. * * @since 0.1 * * @param ContestContestant $contest * * @return array */ protected function getFormFields(ContestContestant $contestant) { $fields = array(); $user = $this->getUser(); $fields['contestant-id'] = array('type' => 'hidden', 'default' => $contestant->getId(), 'id' => 'contest-id'); $fields['contestant-previous-submission'] = array('type' => 'hidden', 'default' => $contestant->getField('submission')); $fields['contestant-submission'] = array('class' => 'ContestSubmissionField', 'label-message' => 'contest-submission-submission', 'validation-callback' => array(__CLASS__, 'validateSubmissionField'), 'options' => array('domains' => implode('|', ContestSettings::get('submissionDomains')), 'value' => $contestant->getField('submission'))); $fields['contestant-realname'] = array('type' => 'text', 'default' => $user->getRealName(), 'label-message' => 'contest-signup-realname', 'required' => true, 'validation-callback' => array(__CLASS__, 'validateNameField')); $fields['contestant-email'] = array('type' => 'email', 'default' => $user->getEmail(), 'label-message' => 'contest-signup-email', 'required' => true, 'validation-callback' => array(__CLASS__, 'validateEmailField')); $fields['contestant-country'] = array('type' => 'select', 'default' => $contestant->getField('country'), 'label-message' => 'contest-signup-country', 'required' => true, 'options' => ContestContestant::getCountriesForInput()); $fields['contestant-challengeid'] = array('type' => 'radio', 'label-message' => 'contest-signup-challenge', 'options' => $this->getChallengesList($contestant), 'default' => $contestant->getField('challenge_id'), 'required' => true, 'validation-callback' => array(__CLASS__, 'validateChallengeField')); $fields['contestant-volunteer'] = array('type' => 'check', 'default' => $contestant->getField('volunteer'), 'label-message' => 'contest-signup-volunteer'); $fields['contestant-wmf'] = array('type' => 'check', 'default' => $contestant->getField('wmf'), 'label-message' => 'contest-signup-wmf'); $hasWMF = $contestant->hasField('wmf'); $fields['contestant-cv'] = array('type' => $hasWMF && $contestant->getField('wmf') ? 'text' : 'hidden', 'default' => $hasWMF ? $contestant->getField('cv') : '', 'label-message' => 'contest-signup-cv', 'validation-callback' => array(__CLASS__, 'validateCVField')); return $fields; }