Commit 496f5b3d authored by Hugh Davenport's avatar Hugh Davenport
Browse files

Split the registration form into js and form



This allows us to alter the form definition directly
before the pieform is created

Change-Id: I3810d3dc4f30bc82dc567fad9338b76bc5296891
Signed-off-by: default avatarHugh Davenport <hugh@catalyst.net.nz>
parent 000290da
...@@ -1994,11 +1994,16 @@ function auth_generate_registration_form($formname, $authname='internal', $goto) ...@@ -1994,11 +1994,16 @@ function auth_generate_registration_form($formname, $authname='internal', $goto)
$form['pluginname'] = 'register'; $form['pluginname'] = 'register';
} }
return array($form, $registerconfirm);
}
function auth_generate_registration_form_js($form, $registerconfirm) {
// The javascript needs to refer to field names, but they are obfuscated in this form, // The javascript needs to refer to field names, but they are obfuscated in this form,
// so construct and build the form in separate steps, so we can get the field names. // so construct and build the form in separate steps, so we can get the field names.
$form = new Pieform($form); $form = new Pieform($form);
$institutionid = $formname . '_' . $form->hashedfields['institution']; $institutionid = $form->get_name() . '_' . $form->hashedfields['institution'];
$reasonid = $formname . '_' . $form->hashedfields['reason']; $reasonid = $form->get_name() . '_' . $form->hashedfields['reason'];
$formhtml = $form->build(); $formhtml = $form->build();
$js = ' $js = '
......
...@@ -176,10 +176,11 @@ if (isset($key)) { ...@@ -176,10 +176,11 @@ if (isset($key)) {
// Default page - show the registration form // Default page - show the registration form
list($formhtml, $js) = auth_generate_registration_form('register', 'internal', '/register.php'); list($form, $registerconfirm) = auth_generate_registration_form('register', 'internal', '/register.php');
if (!$formhtml) { if (!$form) {
die_info(get_string('registeringdisallowed')); die_info(get_string('registeringdisallowed'));
} }
list($formhtml, $js) = auth_generate_registration_form_js($form, $registerconfirm);
$registerdescription = get_string('registerwelcome'); $registerdescription = get_string('registerwelcome');
if ($registerterms = get_config('registerterms')) { if ($registerterms = get_config('registerterms')) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment