コード例 #1
0
ファイル: TaxSetForm.php プロジェクト: spryker/Tax
 /**
  * @param \Symfony\Component\Form\FormBuilderInterface $builder
  *
  * @return $this
  */
 protected function addTaxRates(FormBuilderInterface $builder)
 {
     $builder->add(self::FIELD_TAX_RATES, 'choice', ['expanded' => true, 'multiple' => true, 'label' => 'Tax rates', 'choice_list' => $this->taxSetFormDataProvider->getOptions()[self::FIELD_TAX_RATES], 'constraints' => [new NotBlank()]]);
     $builder->get(self::FIELD_TAX_RATES)->addModelTransformer(new CallbackTransformer(function ($taxRates) {
         if ($taxRates) {
             return (array) $taxRates;
         }
     }, function ($taxRates) {
         return new \ArrayObject($taxRates);
     }));
     return $this;
 }
コード例 #2
0
 /**
  * @param \Spryker\Zed\Tax\Communication\Form\DataProvider\TaxSetFormDataProvider $taxSetFormDataProvider
  *
  * @return \Symfony\Component\Form\FormInterface
  */
 public function createTaxSetForm(TaxSetFormDataProvider $taxSetFormDataProvider)
 {
     $taxSetForm = new TaxSetForm($taxSetFormDataProvider);
     return $this->getFormFactory()->create($taxSetForm, $taxSetFormDataProvider->getData(), ['data_class' => TaxSetTransfer::class]);
 }