Express object form not created
Permalink
Creating Express object worked fine and I need to create form for it as well. The form is created and the field set 'basics' is appearing as well but there are no fields in the Basics field set. Here's the code I used. It's basically a copy paste from the docs but not working.
$entity = Express::getObjectByHandle('user'); if(!is_object($entity)){ $entity = Express::buildObject('user', 'users', 'Users'); $entity->addAttribute('text', 'First Name', 'user_first_name'); $entity->addAttribute('text', 'Last Name', 'user_last_name'); $entity->addAttribute('text', 'Company Name', 'user_company_name'); $entity->addAttribute('text', 'Job Title', 'user_job_title'); $entity->addAttribute('number', 'Mobile', 'user_mobile'); $entity->addAttribute('text', 'Session 1', 'user_session_one'); $entity->addAttribute('text', 'Session 2', 'user_session_two'); $entity->addAttribute('text', 'Download Link', 'user_download_link'); $entity->save(); $form = $entity->buildForm('Form'); $form->addFieldset('Basics') ->addAttributeKeyControl('user_first_name')
Viewing 15 lines of 23 lines. View entire code block.
I Solved this problem. It's just that the default form for view and edit was not being set in edit entity option. Also I couldn't find code to do that either.
Having this exact same problem, can create the Object, Attributes, Form and Fieldset, but not the actual fields being put inside the fieldset
I dropped creating form programmatically lol. Now I have to sit up and do them all manually.... soo frustrating....
I found that if the entity has been created with errors during a package installation, then you delete the package, change the code, reinstall the package - the old entity (assuming it's the same name) is still preserved.
After I uninstalled the package, deleted the entity manually in the Dashboard, reinstalled the package - the default form appeared.
After I uninstalled the package, deleted the entity manually in the Dashboard, reinstalled the package - the default form appeared.
Any help appreciated :)