function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "First Name");
     $LastNameField = new TextField('LastName', "Last Name");
     $TitleField = new TextField('Title', "Title");
     $BioField = new TinyMCEEditorField('Bio', "Bio");
     $BioField->addExtraClass('bio');
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country of Residence', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $WillingVideoField = new CheckboxField('WillingToPresentVideo', "Willing to present via video conference.");
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Willing to travel
     $WillingToTravel = new OptionSetField('WillingToTravel', 'I am willing to travel to events:', array(1 => 'Yes', 0 => 'No'));
     // Countries to travel
     $CountriesToTravelField = new MultiDropdownField('CountriesToTravel', 'Countries willing to travel to:', $CountryCodes);
     $CountriesToTravelField->addExtraClass('travel-field');
     // Spoken Languages
     $LanguageField1 = new TextField('Language[1]', '#1');
     $LanguageField2 = new TextField('Language[2]', '#2');
     $LanguageField3 = new TextField('Language[3]', '#3');
     $LanguageField4 = new TextField('Language[4]', '#4');
     $LanguageField5 = new TextField('Language[5]', '#5');
     // Area of Expertise
     $ExpertiseField1 = new TextField('Expertise[1]', '#1');
     $ExpertiseField2 = new TextField('Expertise[2]', '#2');
     $ExpertiseField3 = new TextField('Expertise[3]', '#3');
     $ExpertiseField4 = new TextField('Expertise[4]', '#4');
     $ExpertiseField5 = new TextField('Expertise[5]', '#5');
     // Links To Presentations
     $PresentationLinkField1 = new TextField('PresentationLink[1]', '#1');
     $PresentationTitleField1 = new TextField('PresentationTitle[1]', '');
     $PresentationLinkField2 = new TextField('PresentationLink[2]', '#2');
     $PresentationTitleField2 = new TextField('PresentationTitle[2]', '');
     $PresentationLinkField3 = new TextField('PresentationLink[3]', '#3');
     $PresentationTitleField3 = new TextField('PresentationTitle[3]', '');
     $PresentationLinkField4 = new TextField('PresentationLink[4]', '#4');
     $PresentationTitleField4 = new TextField('PresentationTitle[4]', '');
     $PresentationLinkField5 = new TextField('PresentationLink[5]', '#5');
     $PresentationTitleField5 = new TextField('PresentationTitle[5]', '');
     $NotesField = new TinyMCEEditorField('Notes', "Notes");
     $NotesField->addExtraClass('notes');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $PhotoField->setValue(null, $speaker);
         $OptInField->setValue($speaker->AvailableForBureau);
         $WillingVideoField->setValue($speaker->WillingToPresentVideo);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $WillingToTravel->setValue($speaker->WillingToTravel);
         $NotesField->setValue($speaker->Notes);
         foreach ($speaker->AreasOfExpertise() as $key => $expertise) {
             if ($key > 4) {
                 break;
             }
             ${'ExpertiseField' . ($key + 1)}->setValue($expertise->Expertise);
         }
         foreach ($speaker->Languages() as $key => $language) {
             if ($key > 4) {
                 break;
             }
             ${'LanguageField' . ($key + 1)}->setValue($language->Language);
         }
         $country_array = array();
         foreach ($speaker->TravelPreferences() as $pref_country) {
             $country_array[] = $pref_country->Country;
         }
         $CountriesToTravelField->setValue(implode(',', $country_array));
         foreach ($speaker->OtherPresentationLinks() as $key => $presentation) {
             ${'PresentationLinkField' . ($key + 1)}->setValue($presentation->LinkUrl);
             ${'PresentationTitleField' . ($key + 1)}->setValue($presentation->Title);
         }
     } elseif ($member) {
         $FirstNameField->setValue($member->FirstName);
         $LastNameField->setValue($member->LastName);
         $BioField->setValue($member->Bio);
         $MemberIDField->setValue($member->ID);
         $IRCHandleField->setValue($member->IRCHandle);
         $TwiiterNameField->setValue($member->TwitterName);
     }
     $fields = new FieldList($FirstNameField, $LastNameField, $TitleField, $CountryField, $BioField, $SpeakerIDField, $MemberIDField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, $IRCHandleField, $TwiiterNameField, $PhotoField, $OptInField, $WillingVideoField, $FundedTravelField, $WillingToTravel, $CountriesToTravelField, $LanguageField1, $LanguageField2, $LanguageField3, $LanguageField4, $LanguageField5, $ExpertiseField1, $ExpertiseField2, $ExpertiseField3, $ExpertiseField4, $ExpertiseField5, $PresentationLinkField1, $PresentationTitleField1, $PresentationLinkField2, $PresentationTitleField2, $PresentationLinkField3, $PresentationTitleField3, $PresentationLinkField4, $PresentationTitleField4, $PresentationLinkField5, $PresentationTitleField5, $NotesField);
     $save_action = new FormAction('addAction', 'Save Speaker Details');
     $save_action->addExtraClass('btn btn-primary');
     $actions = new FieldList($save_action);
     $validator = new RequiredFields('FirstName', 'LastName', 'Title');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "Speaker's First Name");
     $LastNameField = new TextField('LastName', "Speaker's Last Name");
     $TitleField = new TextField('Title', "Speaker's Title");
     $BioField = new TextAreaField('Bio', "Speaker's Bio");
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $Divider = new LiteralField('hr', '<hr/>');
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     $ExpertiseField = new TextareaField('Expertise', 'Topics of interest (one per line)');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $OptInField->setValue($speaker->AvailableForBureau);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $ExpertiseField->setValue($speaker->Expertise);
         $PhotoField->setValue(null, $speaker);
     } elseif ($member) {
         $FirstNameField->setValue($member->FirstName);
         $LastNameField->setValue($member->LastName);
         $BioField->setValue($member->Bio);
         $MemberIDField->setValue($member->ID);
         $IRCHandleField->setValue($member->IRCHandle);
         $TwiiterNameField->setValue($member->TwitterName);
     }
     $fields = new FieldList($FirstNameField, $LastNameField, $TitleField, $BioField, $SpeakerIDField, $MemberIDField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, $IRCHandleField, $TwiiterNameField, $PhotoField, $Divider, $OptInField, $FundedTravelField, $CountryField, $ExpertiseField);
     $actions = new FieldList(new FormAction('addAction', 'Save Speaker Details'));
     $validator = new RequiredFields('FirstName', 'LastName', 'Title');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }