• Register
Plug-in Tutorial Build an EC-CUBE plug-in

Top Commentators

114

1

EC Mike

SHOGUNSHOGUN

32

2

hrbabu

SAMURAISAMURAI

29

3

Sumant Jha

SAMURAISAMURAI

29

4

justcubed

SAMURAISAMURAI

21

5

Ashok Kafle

SAMURAISAMURAI

21

6

shahith

SAMURAISAMURAI

14

7

Jeemusu

KABUKIKABUKI

14

8

Yangsin

KABUKIKABUKI

9

9

Zaw Hlaing Bwar

GEISYAGEISYA

8

10

Fei Liu

GEISYAGEISYA

Ranking Key

  • FUJISANFUJISAN1,000+ posts
  • SAKURASAKURA500+ posts
  • SHOGUNSHOGUN100+ posts
  • NINJYANINJYA50+ posts
  • SAMURAISAMURAI20+ posts
  • KABUKIKABUKI10+ posts
  • GEISYAGEISYALess than 10 posts

Field Empty check by condition in Admin Screen

+3 votes
Will you please tell me how to check empty validation by condition?

For eg. Field are Radiobutton radio1, radio2 and textbox txt1

Condition1: If i  click radio 2 button  then textbox txt1 will disabled. when click confirmation page button in product registration screen, need not  to check any validation.

Condition2: If i click radio1 button then txt1 will enable. when click confirmation page button,  need to check 'EXIST_CHECK','NUM_CHECK', 'MAX_LENGTH_CHECK';

Thanks in advance.
asked 2013-05-13 by shahith (850 points) SAMURAISAMURAI

1 Answer

+1 vote

If I understand you correctly, you require the txt1 input to be validated if the radio button has a value of 1, otherwise you do nothing?

Say your radio buttons HTML markup both have the parameter name="test_radio_button", and their values are 1 (for the enabled button), and 2 (for the disabled button). As below:

<input type="radio" name="test_radio_button" value="1"> Enabled
<input type="radio" name="test_radio_button" value="2"> Disabled


Assuming you are posting the data, you can access the $_POST variable to get the value that was submitted.

You could then wrap the form variable initialization code in a conditional statement.

...

$objFormParam->addParam('TEST RADIO BUTTON', 'test_radio_button', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));

if($_POST['test_radio_button'] == 1) { 

   $objFormParam->addParam('TEXT BOX', 'txt1', INT_LEN, 'n',
   array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));

}else{

   $objFormParam->addParam('TEXT BOX', 'txt1', '', '', array());

}

...


This is completely untested, but thats how I would go about doing it.

Hope that helps as far as the validation goes. If your stuck take a look at another section of the CMS, such as the product registration section. The class for it can be found at:

/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php


As for disabling and enabling the input based on the radio button selected, this would require a little bit of javascript. Take a look at this jsbin to see how it could be achieved with a few lines of jQuery:

http://jsbin.com/onidov/1/

answered 2013-05-14 by Jeemusu (690 points) KABUKIKABUKI
edited 2013-05-14 by Jeemusu
James Morris
         Thank you very much for your answer.
...