/** * This is the class constructor for the YDFormElement_Coutryselect class. * * @param $form The name of the form to which this element is connected. * @param $name The name of the form element. * @param $label (optional) The label for the form element. * @param $attributes (optional) The attributes for the form element. * @param $options (optional) Format string: 'simple' or 'full' */ function YDFormElement_Countryselect($form, $name, $label = '', $attributes = array(), $options = array()) { // initialize parent $this->YDFormElement_Select($form, $name, $label, $attributes, YDList::countries()); // set type $this->_type = 'countryselect'; }
/** * This function returns true if the variable is an array and each element is in opts. * * @param $val The value to test. * @param $opts The array in which the value should be. * @param $formelement (not required) */ function valid($val, $opts = '', $formelement = null) { $opts = $formelement->getOptions(); switch ($formelement->getType()) { case 'checkboxgroup': foreach ($val as $value => $enable) { if (!in_array($value, $opts) || $enable != 'on') { return false; } } return true; case 'select': return in_array($val, $opts); case 'country': YDInclude('YDList.php'); return in_array($val, YDList::countries('keys')); case 'timezone': YDInclude('YDList.php'); return in_array($val, YDList::gmts('keys')); default: die('YDValidateRule "valid" is not supported in element type ' . $formelement->getType()); } }