View Single Post
  #2  
Old 07-22-2018, 12:40 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Adding new property to a product (radio button) for Xcart 5

Quote:
Originally Posted by gior_08
Hello


I found a great help in this link https://devs.x-cart.com/basics/adding_new_property_to_a_product/ so I can add extra properties to products.

This implementation adds a text field in product page (Admin Area).

I want to ask, If I would like to add a radio button what I should change in the code?


Thanks


Hi there.

I am assuming you are referring to a Yes/No button.
If so, you should make the following change to the module.

1. View/FormModel/Product/Info.php
Add the following line

Code:
$schema['default']['myMessage'] = [ 'label' => static::t('My message'), + 'type' => 'XLite\View\FormModel\Type\SwitcherType', 'position' => 900, ];


2. Model/Product.php
Change from


Code:
@Column (type="string")
to
Code:
@Column (type="boolean")


That's pretty much it.
If you already have the demo module installed in your store, don't forget to drop the existing 'myMessage' column from the database before re-deploying. Otherwise it will most likely produce an error that data format is incorrect.
__________________
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