Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

UserDefinedForms - Add more fields choice


Go to End
Reply


10 Posts   1326 Views

Avatar
Kisskool

Community Member, 11 Posts

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 ?

Avatar
Kisskool

Community Member, 11 Posts

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. :)

Go to Top