/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('product', ProductPriceListAwareSelectType::NAME, ['required' => true, 'label' => 'orob2b.product.entity_label', 'create_enabled' => false])->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) { $form = $event->getForm(); /** @var OrderLineItem $item */ $item = $form->getData(); if ($item && $item->isFromExternalSource()) { $this->disableFieldChanges($form, 'product'); $this->disableFieldChanges($form, 'productUnit'); $this->disableFieldChanges($form, 'quantity'); $this->disableFieldChanges($form, 'shipBy'); } }); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('product', ProductSelectType::NAME, ['required' => true, 'label' => 'orob2b.product.entity_label', 'create_enabled' => false])->add('productSku', 'text', ['required' => false, 'label' => 'orob2b.product.sku.label'])->add('freeFormProduct', 'text', ['required' => false, 'label' => 'orob2b.product.entity_label'])->add('price', PriceType::NAME, ['error_bubbling' => false, 'required' => true, 'label' => 'orob2b.order.orderlineitem.price.label', 'hide_currency' => true, 'default_currency' => $options['currency']])->add('priceType', PriceTypeSelectorType::NAME, ['label' => 'orob2b.order.orderlineitem.price_type.label', 'required' => true]); }