Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » The default Login Form - add default value's

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3
Go to End
Author Topic: 3125 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: The default Login Form - add default value's Link to this post

    The Object::useCustomClass() needs to be in your _config.php. This needs to be in CustomLoginForm.php:

    class MyLoginForm extends MemberLoginForm {
    public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) {
    parent::_contstruct($controller, $name, $fields, $actions, $checkCurrentUser);
    $this->Fields()->fieldByName('Email')->setValue('Some default value');
    }
    }

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: The default Login Form - add default value's Link to this post

    You mean the config should look like this?

    Object::useCustomClass('MemberLoginForm', 'CustomLoginForm');
    Object::add_extension('Group', 'GroupDecorator');
    Object::useCustomClass('MemberLoginForm', 'MyLoginForm');

    Placed you function inside CustomLoginForm.php

    but website gives error

    What to do?

  • UncleCheese
    Avatar
    4085 Posts

    Re: The default Login Form - add default value's Link to this post

    What does "gives error" mean?

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: The default Login Form - add default value's Link to this post

    The normal error from silverstripe when you have an error in your code.

    You know:

    WEBSITE ERROR

    on a grey background in a blue-ish square.

  • UncleCheese
    Avatar
    4085 Posts

    Re: The default Login Form - add default value's Link to this post

    Get your site into dev mode so we can see the error.

    Director::set_environment_type('dev');

    You shouldn't be running in live mode while you're still developing.

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: The default Login Form - add default value's Link to this post

    [User Error] Uncaught ReflectionException: Class MyLoginForm does not exist
    GET /bedrijfsprofiel

    Line 89 in /public/sites/www.url.nl/sapphire/core/Object.php
    Source

    80     * @param string $class the class name
    81     * @param mixed $arguments,... arguments to pass to the constructor
    82     * @return Object
    83     */
    84    public static function create() {
    85       $args = func_get_args();
    86       $class = self::getCustomClass(array_shift($args));
    87       
    88       if(version_compare(PHP_VERSION, '5.1.3', '>=')) {
    89          $reflector = new ReflectionClass($class);
    90          return $reflector->newInstanceArgs($args);
    91       } else {
    92          // we're using a PHP install that doesn't support ReflectionClass->newInstanceArgs()
    93          
    94          $args = $args + array_fill(0, 9, null);
    95          return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8]);

  • UncleCheese
    Avatar
    4085 Posts

    Re: The default Login Form - add default value's Link to this post

    Did you create MyLoginForm.php?

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: The default Login Form - add default value's Link to this post

    At first i didn't create the MyLoginForm php, because the function was added on rule 1 of CustomLoginForm.php

    Now i added the function to MyLoginForm.php - and deleted the function from customloginform.php

    After dev/build

    When I enter the page:

    [User Error] Uncaught Exception: Object->__call(): the method '_contstruct' does not exist on ''
    GET /bedrijfsprofiel

    Line 576 in /public/sites/www.url.nl/sapphire/core/Object.php

    3125 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.