diff --git a/src/IDF/Form/Register.php b/src/IDF/Form/Register.php index 866fda9..17d156d 100644 --- a/src/IDF/Form/Register.php +++ b/src/IDF/Form/Register.php @@ -27,8 +27,11 @@ */ class IDF_Form_Register extends Pluf_Form { + protected $request; + public function initFields($extra=array()) { + $this->request = $extra['request']; $login = ''; if (isset($extra['initial']['login'])) { $login = $extra['initial']['login']; @@ -115,6 +118,7 @@ class IDF_Form_Register extends Pluf_Form $user->last_name = $this->cleaned_data['login']; $user->login = $this->cleaned_data['login']; $user->email = $this->cleaned_data['email']; + $user->language = $this->request->language_code; $user->active = false; $user->create(); $from_email = Pluf::f('from_email'); diff --git a/src/IDF/Form/RegisterConfirmation.php b/src/IDF/Form/RegisterConfirmation.php index 3832e9c..f9a616b 100644 --- a/src/IDF/Form/RegisterConfirmation.php +++ b/src/IDF/Form/RegisterConfirmation.php @@ -63,6 +63,7 @@ class IDF_Form_RegisterConfirmation extends Pluf_Form 'size' => 15, ), )); + $this->fields['password'] = new Pluf_Form_Field_Varchar( array('required' => true, 'label' => __('Your password'), diff --git a/src/IDF/Views.php b/src/IDF/Views.php index 4c0e7b0..0cb538a 100644 --- a/src/IDF/Views.php +++ b/src/IDF/Views.php @@ -84,16 +84,19 @@ class IDF_Views function register($request, $match) { $title = __('Create Your Account'); + $params = array('request'=>$request); if ($request->method == 'POST') { - $form = new IDF_Form_Register($request->POST); + $form = new IDF_Form_Register($request->POST, $params); if ($form->isValid()) { $user = $form->save(); // It is sending the confirmation email $url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey'); return new Pluf_HTTP_Response_Redirect($url); } } else { - $init = (isset($request->GET['login'])) ? array('initial' => array('login' => $request->GET['login'])) : array(); - $form = new IDF_Form_Register(null, $init); + if (isset($request->GET['login'])) { + $params['initial'] = array('login' => $request->GET['login']); + } + $form = new IDF_Form_Register(null, $params); } $context = new Pluf_Template_Context(array()); $tmpl = new Pluf_Template('idf/terms.html');