Failing to create DateTime attribute in Express object programmatically

Permalink 1 user found helpful
Hello,

In regards to creating Express object programmatically, I am failing to create DateTime attribute. I am referencing the documentation and the forum post listed below:

-https://documentation.concrete5.org/developers/express/programmatica...
-https://www.concrete5.org/community/forums/chat/unable-to-programmat...

I added the code below in controller.php of my package:

public function install()
    {
        $pkg = parent::install();
        // Create Express object
        $student = Express::buildObject('student', 'students', 'Student', $pkg);
        $student->addAttribute('text', 'First Name', 'first_name');
        $student->addAttribute('text', 'Last Name', 'last_name');
        $student->addAttribute('textarea', 'Bio', 'bio');
        $student->addAttribute('datetime', 'Birthday', 'birthday');
        $student->save();
        // Create form
        $form = $student->buildForm('Form');
        $form->addFieldset('Basics')
            ->addAttributeKeyControl('first_name')
            ->addAttributeKeyControl('last_name')


When I install my package, Concrete5 throws error "Call to a member function getController() on null".

Would anyone guide me how to add a datetime attribute in Express object and its form? Thank you in advance for your help!

 
greg403 replied on at Permalink Reply
Hello,

Did you ever find a solution to this? I am currently having the same issue with both `datetime` and `imagefile` attributes.

Thanks,

Greg