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

How to set minimum integer value?

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 12-23-2015, 11:52 AM
 
kirkbauer kirkbauer is offline
 

Member
  
Join Date: Dec 2015
Posts: 26
 

Default How to set minimum integer value?

If you look at the admin product info screen you can use your mouse scrollwheel to adjust both the Weight and the Quantity in Stock fields. The Weight field won't let you go below zero but the Quantity in Stock field will. I can't figure out how the Weight field sets the minimum value?

(I'm not trying to modify this page I'm just using it for a reference for my module)

Thanks!
__________________
X-Cart Business 5.3.6.8
Reply With Quote
  #2  
Old 12-23-2015, 12:19 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: How to set minimum integer value?

In your yaml file for the field

widgetParameters: { min: XX, max: YY }

You should be able to use similar for form fields as well from the class that shows the form
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 12-23-2015, 02:08 PM
 
kirkbauer kirkbauer is offline
 

Member
  
Join Date: Dec 2015
Posts: 26
 

Default Re: How to set minimum integer value?

I'm just not sure where to set the widgetParameters outside of the yaml file. I don't see any code that uses widgetParameters for the product weight field, for example.

If you inspect the HTML for the product weight it has a data-min property on the field which is what needs to happen however I have no idea how to get that value set.
__________________
X-Cart Business 5.3.6.8
Reply With Quote
  #4  
Old 12-23-2015, 02:38 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: How to set minimum integer value?

Product weight field for the form is set here

/classes/XLite/View/Model/Product.php

and the range is set here - min 0

/classes/XLite/View/Form/Product/Modify/Single.php

The inventory form is set here

/var/www/xc5/xcart52x/classes/XLite/View/Model/InventoryTracking.php

and does not have min/max values set for the quantity
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 12-23-2015, 05:46 PM
 
kirkbauer kirkbauer is offline
 

Member
  
Join Date: Dec 2015
Posts: 26
 

Default Re: How to set minimum integer value?

That helps, thanks! Funny enough it seems the Integer validator doesn't support a range, only the Float version. It seems it would be helpful for integers to be limited in range as well.
__________________
X-Cart Business 5.3.6.8
Reply With Quote
  #6  
Old 12-23-2015, 06:56 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: How to set minimum integer value?

Integer does support range but only positive numbers. I raised this issue with XC few months ago. I had a conversation with them and they did agree integer class as coded in XC5 is wrong and will be corrected in 5.3.x to support negative, positive and 0.

In the mean time you can overwrite the default Integer class with your own to support negative numbers as well.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev 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:05 PM.

   

 
X-Cart forums © 2001-2020