Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

namespace PrestaShopBundle\Form\Admin\Sell\Discount;

use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage;
use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex;
use PrestaShop\PrestaShop\Core\Domain\Discount\DiscountSettings;
use PrestaShopBundle\Form\Admin\Type\TextWithLengthCounterType;
use PrestaShopBundle\Form\Admin\Type\TranslatableType;
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
Expand All @@ -45,24 +47,24 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('names', TranslatableType::class, [
'label' => $this->trans('Discount Name', 'Admin.Catalog.Feature'),
'label_help_box' => $this->trans('The Label help box content is yet to be defined', 'Admin.Catalog.Help'),
'required' => false,
'type' => TextWithLengthCounterType::class,
'required' => true,
'type' => TextType::class,
'constraints' => [
new DefaultLanguage(),
],
'help' => $this->trans(
'The Label help box content is yet to be defined',
'Admin.Catalog.Help'
),
'options' => [
'input' => 'text',
'input_attr' => [
'class' => 'serp-watched-title',
],
'max_length' => DiscountSettings::MAX_NAME_LENGTH,
'position' => 'after',
'constraints' => [
new TypedRegex([
'type' => 'generic_name',
]),
new Length([
'max' => DiscountSettings::MAX_NAME_LENGTH,
'maxMessage' => $this->trans(
'This field cannot be longer than %limit% characters.',
'This field cannot be longer than %limit% characters',
'Admin.Notifications.Error',
['%limit%' => DiscountSettings::MAX_NAME_LENGTH]
),
Expand All @@ -71,10 +73,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
'modify_all_shops' => true,
])
->add('save', SubmitType::class, [
'label' => 'Submit',
'attr' => ['class' => 'btn btn-primary'],
]);
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,27 @@

{% import '@PrestaShop/Admin/macros.html.twig' as ps %}

{{ form(discountForm) }}
{{ form_start(discountForm) }}
{{ form_errors(discountForm) }}
<div class="card">
<h3 class="card-header">
{{ 'Discount information'|trans({}, 'Admin.Catalog.Feature') }}
</h3>
<div class="card-body">
<div class="form-wrapper">

{% block discount_form_rest %}
{{ form_rest(discountForm) }}
{% endblock %}
</div>
</div>
<div class="card-footer">
<a href="{{ path('admin_catalog_price_rules_index') }}" class="btn btn-outline-secondary">
{{ 'Cancel'|trans({}, 'Admin.Actions') }}
</a>
<button class="btn btn-primary float-right">
{{ 'Save'|trans({}, 'Admin.Actions') }}
</button>
</div>
</div>
{{ form_end(discountForm) }}
Loading