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

Change widget class of some field in Checkout

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-28-2018, 01:17 AM
 
Soptareanu Alex Soptareanu Alex is offline
 

Member
  
Join Date: Sep 2016
Posts: 24
 

Default Change widget class of some field in Checkout

I want to change the Field City widget class from
\XLite\View\FormField\Input\Text into \XLite\View\FormField\Select\MyCustomClass(). Is there a way to do this job ?
__________________
alex
Reply With Quote
  #2  
Old 03-30-2018, 01:47 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Change widget class of some field in Checkout

Hi @Alex,

Try to update 'schemaClass' column in the xc_address_field MySQL table for 'city' field.
These values are defined by the sql/xlite_data.yaml file, which is loaded during installation, so the new value should not be overwritten by store re-deployment.

Tony


Quote:
Originally Posted by Soptareanu Alex
I want to change the Field City widget class from
\XLite\View\FormField\Input\Text into \XLite\View\FormField\Select\MyCustomClass(). Is there a way to do this job ?
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 03-30-2018, 02:38 AM
 
Soptareanu Alex Soptareanu Alex is offline
 

Member
  
Join Date: Sep 2016
Posts: 24
 

Default Re: Change widget class of some field in Checkout

Quote:
Originally Posted by tony_sologubov
Hi @Alex,

Try to update 'schemaClass' column in the xc_address_field MySQL table for 'city' field.
These values are defined by the sql/xlite_data.yaml file, which is loaded during installation, so the new value should not be overwritten by store re-deployment.

Tony

Yes, this is was the solution that i found and use but still remains a problem because when i finish my module i want to install in an production env and there i don't have the access to go and hard-code the yaml file. I need a solution if can be posible to do this task when i deploy the module.
__________________
alex
Reply With Quote
  #4  
Old 04-02-2018, 03:18 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Change widget class of some field in Checkout

Quote:
Originally Posted by Soptareanu Alex
Yes, this is was the solution that i found and use but still remains a problem because when i finish my module i want to install in an production env and there i don't have the access to go and hard-code the yaml file. I need a solution if can be posible to do this task when i deploy the module.

There are several ways how to overcome the problem.

1) Decorate \XLite\Model\AddressField class and define its getSchemaClass() method as follows:
Code:
public function getSchemaClass() { if ($this->getServiceName() == 'city') { return '\XLite\Module\DevID\ModuleID\View\FormField\Select\MyCustomClass'; } else { return parent::getSchemaClass(); } }

2) In your module's Main.php file create runBuildCacheHandler() method that will change 'schemaClass' property of the Address Field.

Here is an example script that shows how you can change 'schemaClass' property for 'city' address field:

Code:
<?php include "top.inc.php"; $cityField = \XLite\Core\Database::getRepo('XLite\Model\AddressField')->createQueryBuilder('af') ->andWhere('af.serviceName = :city') ->setParameter('city', 'city') ->getSingleResult(); $cityField->setSchemaClass('\XLite\View\FormField\Input\Text'); \XLite\Core\Database::getEM()->flush();

So, in your module you should define 'schemaClass' as your own value, if the module is enabled:
Code:
\XLite\Core\Database::getRepo('XLite\Model\Module')->isModuleEnabled('DevID\ModuleID')

or if your module is inactive, then you define 'schemaClass' as usual '\XLite\View\FormField\Input\Text'.

Please, let me know if it makes sense to you.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote

The following user thanks tony_sologubov for this useful post:
Soptareanu @Alex (04-05-2018)
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)



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 02:22 PM.

   

 
X-Cart forums © 2001-2020