ZF-7571: Selectbox validation problem with ajax

Description

I have a validation problem with selectboxes which are creating dynamically by ajax. The static ones are working perfect. Is selectbox 0 value valid for Zend Validator? My 0 value is "Please Select" and I should use it. Or any thing else? How can I fixed this problem ? Is it a bug I don't know exactly.

Can anyone help me

Thanks

Deniz

I solve this problem by manually checking the selectboxes like;

if($formValues['productid'] == 0) { $errors .="You should select a product
"; }

Please make a solution with this problem.. I cannot use Zend required or validators!!

Thanks

Comments

I solve this problem by manually checking the selectboxes like;

if($formValues['productid'] == 0) { $errors .="You should select a product
";
}

Please make a solution with this problem.. I cannot use Zend required or validators!!

Thanks

I don't see a problem.

When you want to validate if a value is not empty then use the NotEmpty validator. It does the same as php's empty check and accepts 0 as empty.

I tired NotEmpty validator but it doesnt work again. The ajax created selectboxes didn't work.

like this

$selectBoxHtml = "Please Select....";

        foreach($subProductResults as $value)
        {
            $selectBoxHtml .= "<option value='".$value['id']."'>".$value['subproduct']."</option>";
    }
    $objResponse->assign("subproductid","innerHTML",$selectBoxHtml);

The please select option should not be valid. But your validators say valid for 0 option.

u cn add setMultiOptions ( array(' '=>'----please select----'); instead setMultiOptions ( array('0'=>'----please select----'); it will work :)