2of7 Posted June 23, 2018 Share Posted June 23, 2018 Hi, I use hookCreateAccountForm to add a field to the user registration form, just like that public function hookCreateAccountForm () { return $this->display(__FILE__, 'myfield.tpl'); } Obviously, this adds the field at the end. Now, I was wondering if there is a way to change the position within the form: for example, since mine is a B2B, it would be comfortable in "Company and VAT" block or immediately under the email field. Is there a way to hook it elsewhere? Thanks. Link to comment Share on other sites More sharing options...
2of7 Posted June 24, 2018 Author Share Posted June 24, 2018 (edited) Or alternatively I see that it also exists hook additionalCustomerFormFields but I can not find any practical examples of how I could use it for my purpose. Does anyone have an example for me? [EDIT] Note: I want to point out that this version of Prestashop does not override the customerformatter class, so which solutions to use as an alternative? Edited June 25, 2018 by 2of7 (see edit history) Link to comment Share on other sites More sharing options...
Rodrigo B Laurindo Posted July 13, 2018 Share Posted July 13, 2018 I am also interested in the solution. Anyone? Link to comment Share on other sites More sharing options...
sylvainlepetit Posted August 7, 2021 Share Posted August 7, 2021 (edited) I use this trick to insert my field exactly where I want: public function hookAdditionalCustomerFormFields($params) { // your new field $rpps_field = (new FormField) ->setName('my_new_field') ->setType('text') //->setRequired(true) //Uncomment to set it mandatory ->setLabel($this->l('Label for the new field')); // insert the field into other fields, I choose to put it after teh birthday date $params['fields'] = $this->array_insert_after($params['fields'], 'birthday', ['rpps_id'=>$rpps_field]); // return empty array because the new field already added with current fields return []; } function array_insert_after( array $array, $key, array $new ) { $keys = array_keys( $array ); $index = array_search( $key, $keys ); $pos = false === $index ? count( $array ) : $index + 1; return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) ); } Edited August 7, 2021 by sylvainlepetit translate french comment to english (see edit history) 1 2 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