rvkvino Posted October 16, 2019 Share Posted October 16, 2019 Hello, I have an issue on set default selected value in admin product page. I have created one new field to select the value to the product and it's storing the values into tables but while I edit and check first value only selected default, which ever I have selected and stored value not showing with selected. I have an code like below in src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/pricing.html.twig <div class="col-md-6"> <label class="form-control-label">{{ pricingForm.purity.vars.label }}</label> {{ form_errors(pricingForm.purity) }} {{ form_widget(pricingForm.purity) }} </div> And src/PrestaShopBundle/Form/Admin/Product/ProductPrice.php $this->purity_types = [ $this->translator->trans('22 Ct', [], 'Admin.Global') => '22', $this->translator->trans('18 Ct', [], 'Admin.Global') => '18', ]; ->add( 'purity', FormType\ChoiceType::class, [ 'choices' => $this->purity_types, 'choice_attr' => function ($val) { return [ 'data-rates' => $val, 'data-computation-method' => $val, ]; }, 'attr' => [ 'data-toggle' => 'select2', 'data-minimumResultsForSearch' => '7', ], 'label' => $this->translator->trans('Purity', [], 'Admin.Catalog.Feature'), ] ) But it's only displaying default value not setting selected = 'selected ' on option, I don't know where to set it. Please help anyone to solve this issue. Link to comment Share on other sites More sharing options...
Edvinas Posted November 3, 2020 Share Posted November 3, 2020 found a solution? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now