private function enhanceData($data) { $options = WhereLearntAbout::getItems(); $paletteGen = new PaletteGenerator(); $palette = $paletteGen->generatePalette(sizeof($options), 138, 86, 226); $chartData = []; foreach ($options as $option) { if (!empty($data[$option->getId()])) { $color = $this->chooseColor($palette, $option->getId()); $chartData[] = ['value' => $data[$option->getId()], 'label' => $this->translator->trans($option->getName(), [], 'edk'), 'color' => $color['c'], 'highlight' => $color['h']]; } } return $chartData; }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstName', TextType::class, ['label' => 'First name'])->add('lastName', TextType::class, ['label' => 'Last name'])->add('email', EmailType::class, ['label' => 'E-mail address', 'required' => $this->isMailRequired(), 'attr' => $this->isMailRequired() ? [] : ['help_text' => 'EmailNotRequiredHelpText']])->add('age', IntegerType::class, ['label' => 'Age', 'attr' => ['help_text' => 'AgeHelpText']])->add('sex', ChoiceType::class, ['label' => 'Sex', 'choices' => [1 => 'male', 2 => 'female'], 'multiple' => false, 'expanded' => true])->add('howManyTimes', IntegerType::class, ['label' => 'HowManyTimesField'])->add('whereLearnt', ChoiceType::class, ['label' => 'WhereHaveYouLearntAboutField', 'empty_value' => '-- choose --', 'empty_data' => null, 'choices' => WhereLearntAbout::getFormChoices()])->add('whereLearntOther', TextType::class, array('label' => 'WhereHaveYouLearntAboutContField', 'required' => false))->add('whyParticipate', TextareaType::class, array('label' => 'WhyParticipateField', 'required' => false))->add('save', SubmitType::class, array('label' => $this->getRegisterButtonText())); $builder->add('customAnswer', TextareaType::class, array('label' => $this->getCustomQuestion(), 'required' => $this->isCustomQuestionRequired())); }
public function createRow() { $row = $this->stmt->fetch(PDO::FETCH_ASSOC); if (empty($row)) { return null; } $row['createdAt'] = date('Y-m-d, H:i:s', $row['createdAt']); $row['sex'] = $row['sex'] == 1 ? 'M' : 'F'; $row['whereLearnt'] = $this->trans->trans(WhereLearntAbout::getItem($row['whereLearnt'])->getName(), [], 'edk'); return $row; }
public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addConstraint(new Callback('validate')); $metadata->addPropertyConstraint('firstName', new NotBlank()); $metadata->addPropertyConstraint('firstName', new Length(array('min' => 2, 'max' => 50))); $metadata->addPropertyConstraint('lastName', new NotBlank()); $metadata->addPropertyConstraint('lastName', new Length(array('min' => 2, 'max' => 50))); $metadata->addPropertyConstraint('whereLearnt', new Choice(array('choices' => WhereLearntAbout::getChoiceIds()))); $metadata->addPropertyConstraint('age', new NotBlank()); $metadata->addPropertyConstraint('email', new Email()); $metadata->addPropertyConstraint('whyParticipate', new Length(array('min' => 2, 'max' => 200))); $metadata->addPropertyConstraint('howManyTimes', new NotBlank()); $metadata->addPropertyConstraint('howManyTimes', new Range(['min' => 0])); }