Php validation plugin

jmdc

Member
Hello,

I am using a PHP validation plugin (only in new records) in a dropdown element (element1 in table1) wich values are 0, 1 or 2.
I am having some troubles whit new records. I would like to have always value=2, if this is a new record.
I have this code:

$db = JFactory::getDbo();

if(empty($data)){

return '{table1___element1}' === '2';
}
else{
return false;
}

Could you help me, please? I think it?s basic, but i really don?t understand php code...:(

Thank you very much.!
 
I think it works with just:

$data = '2';

Isn?t it??

Or maybe i put default value to 2...and that works...no need to have a validation plugin!?
 
Yes, if you want to set a default value set it in "Default". It can be modified by the user if he has edit rights on this element.

Validation is usually for validating (and if failing rejecting) user input. In the php (and regex) validation you have the special case that you can do a "Replace" instead of validation. But you don't need it here.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top