ShopAccountForm::__construct PHP Method

__construct() public method

public __construct ( $controller, $name )
    public function __construct($controller, $name)
    {
        $member = Member::currentUser();
        $requiredFields = null;
        if ($member && $member->exists()) {
            $fields = $member->getMemberFormFields();
            $fields->removeByName('Password');
            //TODO: This can be reverted to be $member->getValidator() as soon as this fix lands in framework
            // (most likely 3.4) https://github.com/silverstripe/silverstripe-framework/pull/5098
            $requiredFields = ShopAccountFormValidator::create();
            $requiredFields->addRequiredField('Surname');
        } else {
            $fields = FieldList::create();
        }
        if (get_class($controller) == 'AccountPage_Controller') {
            $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.Save', 'Save Changes')));
        } else {
            $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.Save', 'Save Changes')), FormAction::create('proceed', _t('MemberForm.SaveAndProceed', 'Save and proceed to checkout')));
        }
        parent::__construct($controller, $name, $fields, $actions, $requiredFields);
        $this->extend('updateShopAccountForm');
        if ($member) {
            $member->Password = "";
            //prevents password field from being populated with encrypted password data
            $this->loadDataFrom($member);
        }
    }