How to access a form element in PHP

Saumier

Member
Joomla 2.5.9 Fab 3.0.8

I've been all over the WIKI and forum, and everything I've found doesn't work for me. Here's what I want to do:
I have a radio button; 0 = No 1 = Yes
The next field is a text field that is not required if radio button = 0, but is required if radio button = 1.
I'm trying to write the condition in PHP for notempty validation on the text element to run or not. My biggest problem is the coding to access the radio button element.
I sure would appreciate help on how to do that.
Thanks.
 
If the name of your radio button element is "radio" and the corresponding database table is "mytable", you should write
PHP:
return $data['mytable___radio_raw'] == 1;
in the condition box of your notempty validation
 
Not that for some elements, the data you get from $data can be an array, not a simple value, for things like radio buttons, checkboxes, etc. The best way to handle that is by doing this

PHP:
$radio_value = $data['mytable___radio_raw'];
$radio_value = is_array($radio_value) ? $radio_value[0] : $radio_value;
return $radio_value == '1';

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top