Jump to content

Add custom field in product form


Recommended Posts

Posted (edited)

Hi

I am trying to add a custom field by the name "minimumprice" in product form right after the wholesale_price. I have used the following code to achieve it. But it is not working. Custom field is not displayed in the product form.

 

public function hookActionProductFormBuilderModifier(array $params) {

/** @var $formBuilder \Symfony\Component\Form */

$formBuilder = $params['form_builder']; 

$allFields = $formBuilder->all(); foreach ($allFields as $inputField => $input) {

$formBuilder->remove($inputField); }

foreach ($allFields as $inputField => $input) {

$formBuilder->add($input);

if ($inputField == 'wholesale_price') {

/** @var MoneyType::class \Symfony\Component\Form\Extension\Core\Type\MoneyType */

$formBuilder->add( 'minimumprice', MoneyType::class, ['label' => 'Minimum Price'] );

} } } 

Edited by bk_developer (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More