public function validateSubmission($value, $params) { $options = array('required' => $params->get('required')); $multiselect = $this->_config->get('multiselect'); $messages = $multiselect ? array('required' => 'Please select at least one country.') : array('required' => 'Please select a country.'); $validator = new YValidatorForeach(new YValidatorString($options, $messages), $options, $messages); $clean = $validator->clean($value->get('country')); foreach ($clean as $country) { if (!empty($country) && !in_array($country, $this->_config->get('selectable_countries', array()))) { throw new YValidatorException('Please choose a correct country.'); } } return array('country' => $clean); }
public function validateSubmission($value, $params) { $options = array('required' => $params->get('required')); $messages = array('required' => 'Please select at least one related item.'); $validator = new YValidatorForeach(null, $options, $messages); $clean = $validator->clean($value->get('item')); $table = YTable::getInstance('item'); $selectable_types = $this->_config->get('selectable_types', array()); if (!empty($selectable_types)) { foreach ($clean as $item) { if (!empty($item) && !in_array($table->get($item)->type, $this->_config->get('selectable_types', array()))) { throw new YValidatorException('Please choose a correct related item.'); } } } return array('item' => $clean); }
public function validateSubmission($value, $params) { $options = array('required' => $params->get('required')); $messages = array('required' => 'Please choose an option.'); $validator = new YValidatorForeach(new YValidatorString($options, $messages), $options, $messages); $option = $validator->clean($value->get('option')); return compact('option'); }
public function validateSubmission($value, $params) { $options = array('required' => $params->get('required')); $messages = array('required' => 'Please choose a related category.'); $validator = new YValidatorForeach(new YValidatorString($options, $messages), $options, $messages); $clean = $validator->clean($value->get('category')); $categories = array_keys($this->_item->getApplication()->getCategories()); foreach ($clean as $category) { if (!empty($category) && !in_array($category, $categories)) { throw new YValidatorException('Please choose a correct category.'); } } return array('category' => $clean); }