taoufiqaitali / prestashop-phone-field-for-registration

module to add phone field for registration in prestashop 1.7
GNU General Public License v3.0
9 stars 1 forks source link

choosing the position in form #4

Closed comodino closed 2 years ago

comodino commented 2 years ago

Hi, good job; is possible to change the position in form? for example after the email? i saw that the hook is positioned to bottom thanks

taoufiqaitali commented 2 years ago

Hi @comodino, thanks in order to change the position for the field, you have to overrid this file classes/form/CustomerFormatter.php and change the position for the hook "additionalCustomerFormFields" or create new hook position and assign module to it

comodino commented 2 years ago

thanls, i have creted override:

`<?php /**

class CustomerFormatter extends CustomerFormatterCore {

private $translator;
private $language;

public function __construct(
    TranslatorInterface $translator,
    Language $language
) {
    parent::__construct($translator, $language);
    $this->translator = $translator;
    $this->language = $language;
}

public function getFormat()
{
    $format = parent::getFormat();

    $format = [];

    // New Field added Here --------------------------------------->
    $format['phone'] = (new FormField)
        ->setName('phone')
        ->setLabel(
            $this->translator->trans(
                'Phone', [], 'Shop.Forms.Labels'
            )
        )
        ->setRequired(true);
    //End Of here ------------------------------------------------------>
}

}`

and commented this: public function hookAdditionalCustomerFormFields($params) {/* $formField = new FormField(); $formField->setName('phone'); $formField->setType('text'); $formField->setLabel($this->l('Phone')); $formField->setRequired(true); return array($formField);*/ }

but don't appear

taoufiqaitali commented 2 years ago

You added it to override in prestashop folder?! Cleared cache?? If you added it to override folder in module you have to uninstall and reinstall module again

On Tue, Mar 1, 2022, 22:09 Armando @.***> wrote:

thanls, i have creted override:

`<?php /**

class CustomerFormatter extends CustomerFormatterCore {

private $translator; private $language;

public function construct( TranslatorInterface $translator, Language $language ) { parent::construct($translator, $language); $this->translator = $translator; $this->language = $language; }

public function getFormat() { $format = parent::getFormat();

$format = [];

// New Field added Here --------------------------------------->
$format['phone'] = (new FormField)
    ->setName('phone')
    ->setLabel(
        $this->translator->trans(
            'Phone', [], 'Shop.Forms.Labels'
        )
    )
    ->setRequired(true);
//End Of here ------------------------------------------------------>

}

}`

and commented this: public function hookAdditionalCustomerFormFields($params) {/ $formField = new FormField(); $formField->setName('phone'); $formField->setType('text'); $formField->setLabel($this->l('Phone')); $formField->setRequired(true); return array($formField);/ }

but don't appear

— Reply to this email directly, view it on GitHub https://github.com/taoufiqaitali/prestashop-phone-field-for-registration/issues/4#issuecomment-1055860297, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFOHOXT26Q6OGCGFRT5BK7TU52BRPANCNFSM5PUQA7DQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: <taoufiqaitali/prestashop-phone-field-for-registration/issues/4/1055860297 @github.com>

comodino commented 2 years ago

in module folder....i have unistall and reinstall but i don't see in form...

comodino commented 2 years ago

regphonefield.zip in this i move the entire file CustomerFormatter in folder override form (and add new field)