10378 Posts in 2194 Topics by 1710 members
| Go to End | ||
| Author | Topic: | 594 Views |
-
Re: UserDefinedForms - Add more fields choice

7 June 2012 at 1:18am
Hi ! This is my custom code to add some fields to the form :
mysite/code/MyMember.php
<?php
class MyMember extends DataObjectDecorator {
//Add extra database fields
function extraStatics(){
return array(
'db' => array(
'Pseudo' => 'Varchar(255)',
'TheWebsite' => 'Varchar(255)',
'ConfirmationEmail' => 'Varchar(255)'
)
);
}
public function updateMemberFormFields(&$fields) {
$fields->push(new TextField('Pseudo', 'Pseudo'));
$fields->push(new TextField('TheWebsite', 'TheWebsite'));
$fields->push(new EmailField('ConfirmationEmail', 'ConfirmationEmail'));
}}
?>
mysite/_config.php
Object::add_extension('Member', 'MyMember');
If you find errors or faults, please let me know !
Regarding the confirmation email field, I think the best way to check if fields are matched is :
-First, get the form. Do you think I need to create a new php file, e.g. MyForm.php with an extended MemberProfilePage class ? Or can I get the form into an another class in my MyMember.php ?
I have not yet found how can I get the form...I already tried this code, but I don't know where I need to put it :function getCMSFields() {
$fields = parent::getCMSFields();
//get the email field
$email = $fields->FieldByName('Email');
//then, get the value of the email field, but how ?
//return fields
return $fields;
}
Do you think it's a good way ? Does this code can work ?-Second, extract the email fields values. With loadDataFrom(), or getData(), or something else ?
-Thirdly, check if the email fields are matched before form submitting. I really don't know how can I do this.
-Finally, submit the form.
Is this the best way ? Or do you know something else easier ?
-
Re: UserDefinedForms - Add more fields choice

12 June 2012 at 12:59am
Hi !
For the time being, I have no time to work on this confirmation email field (I must work on a problem with the blog RSS Feed).
But if (or when) I have time, I'ill continue to find the solution.
| 594 Views | ||
| Go to Top |

