PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, June 29, 2022

[FIXED] How to remove validation lastname from prestashop 1.7.8.3 backoffice

 June 29, 2022     prestashop, prestashop-1.7     No comments   

Issue

I have a question how to remove validation from LastName inside client address edit. I need to allow numbers inside this field.

I found here thread Prestashop : Remove Lastname Field Rules Validation From B.O, but this solution is not working.


Solution

Finally, I have caught the issue. You are editing in admin panel and I was sharing code for front end. Please try below steps for admin:

Step 1 - file classes/Address.php

'lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isAnything', 'required' => true, 'size' => 255],

Change this to isAnything

Step 2 - src\PrestaShopBundle\Form\Admin\Sell\Address/CustomerAddressType.php

Change your code to below code:

line 209: add('last_name', TextType::class, [
        'label' => $this->trans('Last name', 'Admin.Global'),
        'help' => $genericInvalidCharsMessage,
        'required' => true,
        'constraints' => [
            new NotBlank([
                'message' => $this->trans(
                    'This field cannot be empty.', 'Admin.Notifications.Error'
                ),
            ]),
            new CleanHtml(),
            new TypedRegex([
                'type' => TypedRegex::TYPE_GENERIC_NAME,
            ]),
            new Length([
                'max' => AddressConstraint::MAX_LAST_NAME_LENGTH,
                'maxMessage' => $this->trans(
                    'This field cannot be longer than %limit% characters',
                    'Admin.Notifications.Error',
                    ['%limit%' => AddressConstraint::MAX_LAST_NAME_LENGTH]
                ),
            ]),
        ],
    ])

Now, you are ready to go and check.



Answered By - Sachin
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing