Hello all, i have a new question for this modules and add fields.
I try to explain with my very bad english... sorry.
So, i use SS_3.1.8 with the MemberProfileExtend off ajshort and all is fully fonctional.
Now, i would like to add un "pre-form", before to send the normal member profil form to register.
-> add a first form with new fields,
-> call another database and return value (dont need to register in the member class),
-> save value in session::
->go to normal form of MemberProfil to register, and insert some default session value.
-> send mail to validation.
Here is what i'm do :
I know in it's don't good to insert in core (but it's only for test):
/memberprofiles/code/MemberProfilePage.php
class MemberProfilePage_Controller extends Page_Controller {
private static $allowed_actions = array (
//ajout formulaire_2
'VerifFamIDForm',
//
'index',
'RegisterForm',
'afterregistration',
'ProfileForm',
'add',
'AddForm',
'confirm',
'show',
);
/**
* My first form - Verif Fam_ID
*/
public function VerifFamIDForm() {
$fields = new FieldList(
new TextField('fac_id', 'Num. Facture'),
new TextField('fac_sum', 'Montant')
);
// Create actions
$actions = new FieldList(
new FormAction('doVerifFamID', 'Vérifier')
);
$required = new RequiredFields('fac_id', 'fac_sum');
//
return new Form($this, 'VerifFamIDForm', $fields, $actions, $required);
}
//
public function doVerifFamID($data1, Form $form1) {
//recup mdb
global $databaseConfig, $databaseAutre;
DB::connect($databaseAutre);
//
$sqlQuery = new SQLQuery();
... bla bla bla
$result1 = $sqlQuery->execute();
//
foreach($result1 as $row1) {
Session::set('fam_id', $row1['bp_family']);
Session::set('fam_mail', $row1['per_email']);
Session::set('fam_name', $row1['per_name']);
}
//
DB::connect($databaseConfig);
return $this->indexRegister();
}
//...other code...
}
memberprofiles/code/MyMemberProfileExtend.php
<?php
class MyMemberProfileExtend extends DataExtension {
private static $db = array(
'Identifiant' => 'Varchar(30)'
);
//
public function updateMemberFormFields(FieldList $fields) {
$fields->push(new TextField('Identifiant', 'Identifiant', Session::get('fam_id')));
//$fields->ReplaceField('Identifiant', new TextField('Identifiant', 'Identifiant F', Session::get('fam_id')));
$fields->ReplaceField('Email', new EmailField('Email', 'E-mail F', Session::get('fam_mail')));
$fields->ReplaceField('Surname', new TextField('Surname', 'Nom F', Session::get('fam_name')));
}
//
public function getCMSFields() {
$fields = parent::getCMSFields();
$this->extend('updateCMSFields', $fields, $actions);
return $fields;
}
}
/memberprofiles/templates/Layout/MemberProfilePage_register.ss
<% if session_fam_id %>
<p>It's ok, you can register now</p>
$Form
<% else %>
<p>Not ok !</p>
VerifFamIDForm
<% end_if %>
All it's ok. But when i receive the registration mail to confirm, there is no "...?key=" key value (empty).
So in the database member, the new member have an empty TempIDHash (NULL) and no ProfilePageID (0).
All other fields are good. The new field "fam_id" too. It's ok.
I'm lost in code... Please, if just you have an idea ...?!
Thanks to read.