@@ -21,13 +21,15 @@ class UnitType extends AbstractType | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | |||
dump($options); | |||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event, $options) { | |||
$builder = $event->getForm()->getParent(); | |||
$builder->add('unit', ChoiceType::class, [ | |||
'required' => true, | |||
'translation_domain'=>'lcshop', | |||
'expanded'=>true, | |||
'data'=> $options['data'], | |||
'choices' => [ | |||
'field.default.percent' => 'percent', | |||
'field.default.amount' => 'amount' |
@@ -36,9 +36,11 @@ abstract class ReductionCredit extends AbstractEntity implements ReductionInterf | |||
protected $merchant; | |||
public function __construct() | |||
{ | |||
$this->users = new ArrayCollection(); | |||
$this->unit = 'amount'; | |||
} | |||
public function __toString() |
@@ -8,7 +8,7 @@ | |||
<div class="col-12"> | |||
{{ form_row(form.appliedTo, {"attr" :{"v-model" : 'reductionAppliedTo'}}) }} | |||
</div> | |||
<div class="col-12" v-show="reductionAppliedTo != 'shipping'"> | |||
<div class="col-12" v-show="reductionAppliedTo != 'delivery'"> | |||
{{ form_row(form.freeShipping) }} | |||
</div> | |||
{{ macros.fieldReductionUnit(form) }} |