Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Make A Field Mandatory In Product Detail Page Tabs Rate Topic   - - - - -

 
  • fleaffair
  • Senior Member
  • Members
  • Join Date: 11-Jun 14
  • 537 posts

Posted 03 June 2015 - 05:00 AM #1

There are different tabs on the product detail page and what I want is to make few fields mandatory on different tabs so that if the vendor creates a new product he should get an error message if all the mandatory fields ( on different tabs) are not filled?

I tried using the class cm-required on the fields in tpl field but that is just a display of asterisk not a field check. Please advise?
Warm Regards,
Admin | MVE: 4.2.4

 

Posted 03 June 2015 - 08:15 AM #2

hi,

It should work via CSS class "cm-required" so possibly it was added to wrong HTML tags. Please check how it should look like:
<div class="control-group">
     <label for="product_field" class="control-label cm-required">Field</label>
     <div class="controls">
          <input class="input-large" type="text" name="field" id="product_field" value="">
     </div>
</div>

Comments:
1. CSS class "cm-required" is added to LABEL
2. FOR attribtute for LABEL = ID attribute for INPUT

Please check it and let us know result.

best regards,
WSA team

 
  • fleaffair
  • Senior Member
  • Members
  • Join Date: 11-Jun 14
  • 537 posts

Posted 08 June 2015 - 10:09 AM #3

Damir,

Thanks for the response, I did the same thing but now I have figured out why its not happening. I applied this on the weight field in shipping and by default its adding 0.00 in the content , how can we validate that the content is not 0.00 and then raise an alert that please fill this value while creating a product.

Thanks.
Warm Regards,
Admin | MVE: 4.2.4

 

Posted 09 June 2015 - 08:28 AM #4

You may remove the zero value 0.00 and make field required. For this please open the file "design/backend/templates/views/products/components/products_shipping_settings.tpl" and replace the line:


<label class="control-label" for="product_weight">{__("weight")} ({$settings.General.weight_symbol nofilter}):</label>

with:


<label class="control-label cm-required" for="product_weight">{__("weight")} ({$settings.General.weight_symbol nofilter}):</label>

and line


<input type="text" name="product_data[weight]" id="product_weight" size="10" value="{$product_data.weight|default:"0"}" class="input-long" />
with


<input type="text" name="product_data[weight]" id="product_weight" size="10" value="{$product_data.weight}" class="input-long" />

p.s. Also please don't forget to clear template cache.

Let us know if it helps.

best regards,
WSA team

 
  • fleaffair
  • Senior Member
  • Members
  • Join Date: 11-Jun 14
  • 537 posts

Posted 19 June 2015 - 08:20 AM #5

Hi Damir,

Thanks for this it works but now the issue is since the Shipping Tab is having this Weight field , if the user is not on the Shipping Tab he never comes to know that the validation error is coming. Can we somehow show a popup ( javascript) error to let the user know about this or may be some other notification ?

Thanks.
Warm Regards,
Admin | MVE: 4.2.4

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22816 posts

Posted 19 June 2015 - 09:16 AM #6

The system should open the corresponding tab to the user. It is default CS-Cart behavior. Please check

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 

Posted 19 June 2015 - 11:27 AM #7

hi,

eComLabs is right, it should work by default.
If no, please provide us with the temporary FTP access, our specialists can check the issue.

best regards,
WSA team

 
  • fleaffair
  • Senior Member
  • Members
  • Join Date: 11-Jun 14
  • 537 posts

Posted 19 June 2015 - 11:35 AM #8

Awesome, it works post cleaning the cache. :shock: Strange behavior
Warm Regards,
Admin | MVE: 4.2.4

 
  • emall
  • Advanced Member
  • Members
  • Join Date: 15-Sep 20
  • 123 posts

Posted 17 February 2021 - 09:22 PM #9

Could you please explain where the CS class should be added in order to make a feature "rewuired"? I have a feature (size) which I would like to make a required field. How can I do this?

 

Many thanks in advance



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22816 posts

Posted 18 February 2021 - 06:16 AM #10

You can add cm-required class to label elements here

 

design/backend/templates/views/products/components/product_assign_feature.tpl

 

This file has hooks as well


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • emall
  • Advanced Member
  • Members
  • Join Date: 15-Sep 20
  • 123 posts

Posted 18 February 2021 - 08:14 PM #11

Thank you ecom. Can you please indicate what I should replace with what, so as not to mess anything up. I remind you that I need to make a specific feature required (i.e. size).

 

Thanks again, much obliged



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22816 posts

Posted 19 February 2021 - 07:18 AM #12

Try to replace

<label class="control-label" for="feature_{$feature_id}">

with

<label class="control-label{if $feature_id == 123} cm-required{/if}" for="feature_{$feature_id}">

where 123 - feature ID, can be found in the admin panel

 

(!) Not tested


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • emall
  • Advanced Member
  • Members
  • Join Date: 15-Sep 20
  • 123 posts

Posted 19 February 2021 - 09:15 PM #13

Thanks eCom but it didn't work. I get a "service unavailable" screen when trying to sreate a new product or see a product which is already in store.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12156 posts

Posted 21 February 2021 - 07:24 PM #14

Right click/inspect that screen and post the comments which is the stack trace and report of the error.  Most likely you have a typo in your Smarty syntax.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22816 posts

Posted 22 February 2021 - 06:22 AM #15

Thanks eCom but it didn't work. I get a "service unavailable" screen when trying to sreate a new product or see a product which is already in store.

 

Our code is correct. Please make sure that everything is copied correctly


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • emall
  • Advanced Member
  • Members
  • Join Date: 15-Sep 20
  • 123 posts

Posted 03 March 2021 - 06:58 PM #16

Tanks eCom. It works up to the point that it makes the feature "required". However, even when I do select a feature, it still marks it in red (message saying the feature is required) and does not let me save. Any ideas?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22816 posts

Posted 04 March 2021 - 04:24 AM #17

It is hard to say anything without examination, sorry


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • shanower
  • Advanced Member
  • Members
  • Join Date: 27-Jul 19
  • 98 posts

Posted 17 November 2021 - 03:11 AM #18

I tested the code from eCom Labs and it really works, however it makes also impossible to save the product since even when you fill the feature with information it still send a warning message saying that the field is required like if it was empty. I am trying to debug to find a solution.



 
  • emall
  • Advanced Member
  • Members
  • Join Date: 15-Sep 20
  • 123 posts

Posted 17 November 2021 - 08:32 PM #19

I tested the code from eCom Labs and it really works, however it makes also impossible to save the product since even when you fill the feature with information it still send a warning message saying that the field is required like if it was empty. I am trying to debug to find a solution.

This was exactly how it was for me as well. Let me know if you manage to find a solution.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12156 posts

Posted 17 November 2021 - 09:37 PM #20

Make sure that 

for="feature_{$feature_id}

 

Matches the id of your form field.  I.e. if you have an input element named

<input id="feature_123" blahh.../>

Then the for parameter in the label tag must resolve to "feature_123".


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.