This topic contains 2 replies, has 2 voices, and was last updated by Guillaume Deneux 5 years, 6 months ago.
- Topic
I added a field from the backoffice on the entity rfq, I wish to make this option mandatory and type email.
To add these constraints I am looking to modify the form:
vendor/oro/commerce/src/Oro/Bundle/RFPBundle/Form/Type/Frontend/RequestType.php:29I followed the documentation:
https://symfony.com/doc/current/bundles/FOSUserBundle/overriding_forms.htmlAll my tests lead me to the same error:
Cannot read index “firstName” from object of type “Oro\Bundle\RFPBundle\Entity\Request” because it doesn’t implement \ArrayAccess.
I created the class RequestType from namespace namespace Tbd\RFPBundle\Form\Type\Frontend :
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667class RequestType extends AbstractType{const NAME = 'Tbd_rfp_frontend_request';/*** @var string*/protected $dataClass;/*** @param string $dataClass*/public function setDataClass($dataClass){$this->dataClass = $dataClass;}public function getParent(){return \Oro\Bundle\RFPBundle\Form\Type\Frontend\RequestType::NAME;}/*** {@inheritdoc}*/public function buildForm(FormBuilderInterface $builder, array $options){$constraints = [new NotBlank(),new Email()];$s_email_agent = $builder->get('s_email_agent')->getOptions();$s_email_agent['required']=true;$s_email_agent['constraints'] = $constraints;$builder->add('s_email_agent',TextType::class, $s_email_agent);}/*** {@inheritdoc}*/public function configureOptions(OptionsResolver $resolver){$resolver->setDefaults(['data_class' => $this->dataClass]);}/*** {@inheritdoc}*/public function getName(){return $this->getBlockPrefix();}/*** {@inheritdoc}*/public function getBlockPrefix(){return static::NAME;}In my file .yml
123456oro_rfp.form.type.frontend_request:class: 'Tbd\RFPBundle\Form\Type\Frontend\RequestType'calls:- [setDataClass, ['%oro_rfp.entity.request.class%']]tags:- { name: form.type, alias: oro_rfp_frontend_request }What is wrong ?
thanking you
The forum ‘OroCommerce’ is closed to new topics and replies.