Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Error when creating widget

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-24-2017, 01:26 AM
 
mm23456 mm23456 is offline
 

Member
  
Join Date: May 2017
Posts: 11
 

Default Error when creating widget

Hi,

I'm trying to build a custom page following the tutorial:
http://devs.x-cart.com/en/basics/new_form/model_editing.html

However, when I try to add the widget to the twig file, an error occurs (error log is below). Controller is VendorRegistration.

[24-May-2017 09:38:56 Europe/Berlin] PHP Error: Using $this when not in object context in /var/www/html/xcart-business/xcart/var/run/classes/XLite/Module/XC/ThemeTweaker/View/AView.php on line 293
[24-May-2017 09:38:56 Europe/Berlin] PHP Stack trace:
[24-May-2017 09:38:56 Europe/Berlin] PHP 1. {main}() /var/www/html/xcart-business/xcart/admin.php:0
[24-May-2017 09:38:56 Europe/Berlin] PHP 2. XLite->processRequest() /var/www/html/xcart-business/xcart/admin.php:18
[24-May-2017 09:38:56 Europe/Berlin] PHP 3. XLite->processRequest() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Module/XC/Concierge/XLite.php:43
[24-May-2017 09:38:56 Europe/Berlin] PHP 4. XLite->processRequest() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Module/XC/MailChimp/XLite.php:21
[24-May-2017 09:38:56 Europe/Berlin] PHP 5. XLite\Module\ModuleID\Registration\Controller\Admi n\VendorRegistration->processRequest() /var/www/html/xcart-business/xcart/var/run/classes/XLiteAbstract.php:665
[24-May-2017 09:38:56 Europe/Berlin] PHP 6. XLite\Module\ModuleID\Registration\Controller\Admi n\VendorRegistration->processRequest() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Module/XC/ThemeTweaker/Controller/AController.php:23
[24-May-2017 09:38:56 Europe/Berlin] PHP 7. XLite\View\Controller->display() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Controller/AControllerAbstract.php:667
[24-May-2017 09:38:56 Europe/Berlin] PHP 8. XLite\View\Controller->displayPage() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/ControllerAbstract.php:60
[24-May-2017 09:38:56 Europe/Berlin] PHP 9. XLite\View\Controller->prepareContent() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/ControllerAbstract.php:245
[24-May-2017 09:38:56 Europe/Berlin] PHP 10. XLite\View\Controller->prepareContent() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Module/QSL/CloudSearch/View/Controller.php:101
[24-May-2017 09:38:56 Europe/Berlin] PHP 11. XLite\View\Content->getContent() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/ControllerAbstract.php:216
[24-May-2017 09:38:56 Europe/Berlin] PHP 12. XLite\View\Content->display() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/AViewAbstract.php:355
[24-May-2017 09:38:56 Europe/Berlin] PHP 13. XLite\View\Content->display() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/Content.php:48
[24-May-2017 09:38:56 Europe/Berlin] PHP 14. XLite\View\Content->doDisplay() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/AViewAbstract.php:292
[24-May-2017 09:38:56 Europe/Berlin] PHP 15. XLite\Core\Templating\TwigEngine->display() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/AViewAbstract.php:329
[24-May-2017 09:38:56 Europe/Berlin] PHP 16. __TwigTemplate_eec6ed5cf92027cb7427cae4b2c467e05ab 0776f86a32e3e29d37e2cce7672a7->display() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Core/Templating/TwigEngine.php:78
....
[24-May-2017 09:38:56 Europe/Berlin] PHP 44. XLite\Module\ModuleID\Registration\View\FormModel\ VendorRegistration->defineSchema() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/FormModel/AFormModel.php:754
[24-May-2017 09:38:56 Europe/Berlin] PHP 45. XLite\Module\ModuleID\Registration\View\FormModel\ VendorRegistration->prepareFields() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/FormModel/AFormModel.php:734
[24-May-2017 09:38:56 Europe/Berlin] PHP 46. XLite\Module\ModuleID\Registration\View\FormModel\ VendorRegistration->prepareSectionFields() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/FormModel/AFormModel.php:639
[24-May-2017 09:38:56 Europe/Berlin] PHP 47. XLite\Module\ModuleID\Registration\View\FormModel\ VendorRegistration->collectFieldResources() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/FormModel/AFormModel.php:676
[24-May-2017 09:38:56 Europe/Berlin] PHP 48. XLite\Module\ModuleID\Registration\View\FormModel\ VendorRegistration->collectFieldResource() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/FormModel/AFormModel.php:708
[24-May-2017 09:38:56 Europe/Berlin] PHP 49. XLite\Module\CDev\GoogleAnalytics\View\AView::getC ommonFiles() /var/www/html/xcart-business/xcart/var/run/classes/XLite/View/FormModel/AFormModel.php:720
[24-May-2017 09:38:56 Europe/Berlin] PHP 50. XLite\Module\XC\ThemeTweaker\View\AView::getCommon Files() /var/www/html/xcart-business/xcart/var/run/classes/XLite/Module/CDev/GoogleAnalytics/View/AView.php:25

Any ideas why this happens?

Thanks a lot!
__________________
X-cart 5.3.2.9
Multivendor
Reply With Quote
  #2  
Old 05-24-2017, 04:34 AM
 
mm23456 mm23456 is offline
 

Member
  
Join Date: May 2017
Posts: 11
 

Default Re: Error when creating widget

If anyone encounters this error: in my case it was due to inappropriate field class for type parameter in schema.
__________________
X-cart 5.3.2.9
Multivendor
Reply With Quote
  #3  
Old 05-24-2017, 11:57 AM
 
mm23456 mm23456 is offline
 

Member
  
Join Date: May 2017
Posts: 11
 

Default Re: Error when creating widget

Following the same tutorial, I created a new form model and when I open the form, enter some text in the field and then leave the field, the field is emptied. It is done from JavaScript, but I am not able to understand why it happens.

As far as I could see, it only happens with Symfony types and not with ones defined by X-cart, but the X-cart does not offer types such as email, password etc that extend Symfony\Component\Form\AbstractType.

I have been through the developer site and followed the tutorial for creating editable form model, but still could not solve the problem.

Do you have any suggestions?

Thanks!
__________________
X-cart 5.3.2.9
Multivendor
Reply With Quote
  #4  
Old 05-29-2017, 04:25 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Error when creating widget

I believe you cannot use Symfony types without a wrapping class in X-Cart 5. Please check existing classes in \XLite\View\FormModel and \XLite\View\FormField namespaces.

As for JavaScript emptying your custom field: I think this may happen because of Vue.js. Recent XC5 versions use Vue.js for some of forms, and this library maps data in JavaScript model objects to form fields automatically. Perhaps, your custom field is not mapped, so it stays empty. Please check how existing fields use the "v-model" attribute.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #5  
Old 05-29-2017, 06:50 AM
 
mm23456 mm23456 is offline
 

Member
  
Join Date: May 2017
Posts: 11
 

Default Re: Error when creating widget

Some of the X-cart classes use Symfony types directly. I also tried to wrap Symfony type in the same manner the X-cart classes do. None of these helped.

What did work though is switching to the way described here:

http://devs.x-cart.com/en/basics/model_editing_page.html

It seems to be the older approach, but it works.
__________________
X-cart 5.3.2.9
Multivendor
Reply With Quote

The following user thanks mm23456 for this useful post:
qualiteam (05-29-2017)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:02 AM.

   

 
X-Cart forums © 2001-2020