2012-09-04, 11:23:14
So... I still fighting with the problem of the checkbox validation. I don't want to bother you, but it's really important for me. I guess it's time to learn PHP...
Anyway, I think that the problem can be fixed adding few lines to the function check_validity()
/**
* Check if field value is valid
* Mean different things depending on field type
* @return boolean
*/
public function check_validity()
{
if($this->blacklisted()) return False;
switch($this->type) {
case 'email':
$pattern = '`^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$`i';
if(preg_match($pattern, $this->value)) return True;
else return False;
case 'phone':
$pattern = '`^\+?[-0-9(). ]{6,}$$`i';
if(preg_match($pattern, $this->value)) return True;
else return False;
......
I have tryed with this:
case 'radio':
if($this->value == "yes")
return True;
else return False;
with this html:
<div class="field radio">
<div class="label"><label for="p01-contact1_field4">I accept the terms&conditions<strong style="color:red">*</strong></label></div>
<input id="p01-contact1_field4_option0" type="radio" name="p01-contact_fields[4]" value=" yes" /> yes
<input id="p01-contact1_field4_option1" type="radio" name="p01-contact_fields[4]" value=" no" checked /> no</div>
But it doesn't work. Actually, this way it always return the error "field_radio"...
I have tryed also with the function $_post... e.g.,
if($_post['p01-contact_fields[4]'] == "yes"))
No way...
Great plugin and great cms anyway...
Anyway, I think that the problem can be fixed adding few lines to the function check_validity()
/**
* Check if field value is valid
* Mean different things depending on field type
* @return boolean
*/
public function check_validity()
{
if($this->blacklisted()) return False;
switch($this->type) {
case 'email':
$pattern = '`^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$`i';
if(preg_match($pattern, $this->value)) return True;
else return False;
case 'phone':
$pattern = '`^\+?[-0-9(). ]{6,}$$`i';
if(preg_match($pattern, $this->value)) return True;
else return False;
......
I have tryed with this:
case 'radio':
if($this->value == "yes")
return True;
else return False;
with this html:
<div class="field radio">
<div class="label"><label for="p01-contact1_field4">I accept the terms&conditions<strong style="color:red">*</strong></label></div>
<input id="p01-contact1_field4_option0" type="radio" name="p01-contact_fields[4]" value=" yes" /> yes
<input id="p01-contact1_field4_option1" type="radio" name="p01-contact_fields[4]" value=" no" checked /> no</div>
But it doesn't work. Actually, this way it always return the error "field_radio"...
I have tryed also with the function $_post... e.g.,
if($_post['p01-contact_fields[4]'] == "yes"))
No way...
Great plugin and great cms anyway...