本文整理汇总了PHP中Zend_Form_Element_Xhtml::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Xhtml::isValid方法的具体用法?PHP Zend_Form_Element_Xhtml::isValid怎么用?PHP Zend_Form_Element_Xhtml::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Xhtml
的用法示例。
在下文中一共展示了Zend_Form_Element_Xhtml::isValid方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
/**
* Override isValid()
*
* Ensure that validation error messages mask password value.
*
* @param string $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
{
foreach ($this->getValidators() as $validator) {
if ($validator instanceof Zend_Validate_Abstract) {
$validator->setObscureValue(true);
}
}
return parent::isValid($value, $context);
}
示例2: isValid
public function isValid($value, $context = null)
{
if (is_array($value)) {
$value = $value['year'] . '-' . $value['month'] . '-' . $value['day'];
if ($value == '--') {
$value = null;
}
}
return parent::isValid($value, $context);
}
示例3: isValid
public function isValid($value, $context = null)
{
if (!is_array($value)) {
return false;
}
$result = checkdate((int) $value['month'], (int) $value['day'], (int) $value['year']);
if ($result == false) {
$value = null;
}
if ($this->max_year && (int) $value['year'] > $this->max_year || $this->min_year && (int) $value['year'] < $this->min_year) {
$value = null;
}
return parent::isValid($value, $context);
}
示例4: isValid
/**
* Validate upload
*
* @param string $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
{
if (isset($_FILES[$this->getName()])) {
$value = $_FILES[$this->getName()]['tmp_name'];
$context = $_FILES[$this->getName()];
$context['destination'] = $this->_destination;
}
$isValid = parent::isValid($value, $context);
// If it's valid, we move the file to its final destination
if ($isValid && isset($this->_destination)) {
$destination = is_dir($this->_destination) ? $this->_destination . '/' . $context['name'] : $this->_destination;
move_uploaded_file($value, $destination);
}
return $isValid;
}
示例5: isValid
public function isValid($value, $context = null)
{
$fieldName = $this->getName();
$auxiliaryFieldsNames = $this->getDayMonthYearTimeFieldNames($fieldName);
if (isset($context[$auxiliaryFieldsNames['day']]) && isset($context[$auxiliaryFieldsNames['month']]) && isset($context[$auxiliaryFieldsNames['year']]) && isset($context[$auxiliaryFieldsNames['hour']]) && isset($context[$auxiliaryFieldsNames['minutes']]) && isset($context[$auxiliaryFieldsNames['ampm']])) {
if ($context[$auxiliaryFieldsNames['year']] == '-' || $context[$auxiliaryFieldsNames['month']] == '-' || $context[$auxiliaryFieldsNames['day']] == '-' || $context[$auxiliaryFieldsNames['hour']] == '-' || $context[$auxiliaryFieldsNames['minutes']] == '-' || $context[$auxiliaryFieldsNames['ampm']] == '-') {
$value = null;
} else {
$hour = $context[$auxiliaryFieldsNames['hour']];
if ($context[$auxiliaryFieldsNames['ampm']] == 'pm') {
$hour += 12;
}
$value = str_pad($context[$auxiliaryFieldsNames['year']], 4, '0', STR_PAD_LEFT) . '-' . str_pad($context[$auxiliaryFieldsNames['month']], 2, '0', STR_PAD_LEFT) . '-' . str_pad($context[$auxiliaryFieldsNames['day']], 2, '0', STR_PAD_LEFT) . ' ' . str_pad($hour, 2, '0', STR_PAD_LEFT) . ':' . str_pad($context[$auxiliaryFieldsNames['minutes']], 2, '0', STR_PAD_LEFT) . ':00';
}
$this->setValue($value);
}
return parent::isValid($value, $context);
}
示例6: isValid
public function isValid($value, $context = null)
{
// for a file upload, the value is not in the POST array, it's in $_FILES
$key = $this->getName();
if ($value === null) {
if (isset($_FILES[$key])) {
$value = $_FILES[$key];
}
}
// auto insert ValidFile validator
if ($this->isRequired() && $this->autoInsertValidFileValidator() && !$this->getValidator('ValidFile')) {
$validators = $this->getValidators();
$validFile = array('validator' => 'ValidFile', 'breakChainOnFailure' => true);
array_unshift($validators, $validFile);
$this->setValidators($validators);
// do not use the automatic NotEmpty Validator as ValidFile replaces it
$this->setAutoInsertNotEmptyValidator(false);
}
return parent::isValid($value, $context);
}
示例7: isValid
/**
* Is the value provided valid?
*
* Autoregisters InArray validator if necessary.
*
* @param string $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
{
if ($this->registerInArrayValidator()) {
if (!$this->getValidator('InArray')) {
$multiOptions = $this->getMultiOptions();
$options = array();
foreach ($multiOptions as $opt_value => $opt_label) {
// optgroup instead of option label
if (is_array($opt_label)) {
$options = array_merge($options, array_keys($opt_label));
} else {
$options[] = $opt_value;
}
}
$this->addValidator('InArray', true, array($options));
}
}
return parent::isValid($value, $context);
}
示例8: isValid
/**
* Is the captcha valid?
*
* @param mixed $value
* @param mixed $context
* @return boolean
*/
public function isValid($value, $context = null)
{
$this->getCaptcha()->setName($this->getName());
$belongsTo = $this->getBelongsTo();
if (empty($belongsTo) || !is_array($context)) {
return parent::isValid($value, $context);
}
$name = $this->getFullyQualifiedName();
$root = substr($name, 0, strpos($name, '['));
$segments = substr($name, strpos($name, '['));
$segments = ltrim($segments, '[');
$segments = rtrim($segments, ']');
$segments = explode('][', $segments);
array_unshift($segments, $root);
array_pop($segments);
$newContext = $context;
foreach ($segments as $segment) {
if (array_key_exists($segment, $newContext)) {
$newContext = $newContext[$segment];
}
}
return parent::isValid($value, $newContext);
}
示例9: isValid
public function isValid($value, $context = null)
{
// Empty
if ($this->getAllowEmpty() && (empty($value) || is_array($value) && 0 == count(array_filter($value)))) {
return parent::isValid($value, $context);
}
$this->setValue($value);
$value = $this->getValue();
// Normal processing
if (is_string($value)) {
if (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})( (\\d{2}):(\\d{2})(:(\\d{2}))?)?$/', $value, $m)) {
$year = $m[1];
$month = $m[2];
$day = $m[3];
$hour = @$m[5];
$minute = @$m[6];
} else {
$this->addError('Please select a date from the calendar.');
return false;
}
} else {
if (is_array($value)) {
$m = explode('/', $value['date']);
if (count($m) === 3) {
$year = $m[stripos($this->dateFormat, 'y')];
$month = $m[stripos($this->dateFormat, 'm')];
$day = $m[stripos($this->dateFormat, 'd')];
} else {
$year = null;
$month = null;
$day = null;
}
if (isset($value['hour']) && in_array($value['hour'], $this->getHourOptions())) {
$hour = $value['hour'];
}
if (isset($value['minute']) && in_array($value['minute'], $this->getMinuteOptions())) {
$minute = $value['minute'];
}
if (isset($value['ampm']) && in_array($value['ampm'], $this->getAMPMOptions())) {
if ($value['ampm'] == 'pm' && $hour < 12 && null !== $hour) {
$hour += 12;
} else {
if ($value['ampm'] == 'AM' && $hour == 12) {
$hour = 0;
}
}
}
}
}
// Check validity
if (!$year || !$month || !$day) {
$this->addError('Please select a date from the calendar.');
return false;
}
if (!$hour || !$minute) {
$this->addError('Please select a time from the dropdown.');
return false;
}
if ($month < 1 || $month > 12) {
$this->addError('Please select a date from the calendar.');
return false;
}
if ($day < 1 || $day > 31) {
$this->addError('Please select a date from the calendar.');
return false;
}
//if( $this->_useMilitaryTime() ) {
if ($hour < 0 || $hour > 23) {
$this->addError('Please select a time from the dropdown.');
return false;
}
//} else {
// if( $hour < 1 || $hour > 12 ) {
// $this->addError('Please select a time from the dropdown.');
// return false;
// }
//}
if ($minute < 0 || $minute >= 60) {
$this->addError('Please select a time from the dropdown.');
return false;
}
return parent::isValid($value, $context);
}
示例10: isValid
/**
* Validate element value
*
* If a translation adapter is registered, any error messages will be
* translated according to the current locale, using the given error code;
* if no matching translation is found, the original message will be
* utilized.
*
* Note: The *filtered* value is validated.
*
* @param mixed $value
* @param mixed $context
* @return boolean
*/
public function isValid($value, $context = null)
{
$valid = parent::isValid($value, $context);
// Subforms are set bet setValue() called by parent::isValid()
if ($this->_subForms) {
foreach ($value as $id => $data) {
$valid = $this->_subForms[$id]->isValid($data) && $valid;
}
}
return $valid;
}
示例11: isValid
public function isValid($value, $context = null)
{
// Empty
if ($this->getAllowEmpty() && (empty($value) || is_array($value) && 0 == count(array_filter($value)))) {
return parent::isValid($value, $context);
}
$this->setValue($value);
$value = $this->getValue();
// Normal processing
if (is_string($value)) {
if (preg_match('/^(\\d+)-(\\d+)-(\\d+)$/', $value, $m)) {
$year = $m[stripos($this->dateFormat, 'y') + 1];
$month = $m[stripos($this->dateFormat, 'm') + 1];
$day = $m[stripos($this->dateFormat, 'd') + 1];
} else {
$this->addError('Is not a right date format');
return false;
}
} else {
if (is_array($value)) {
$m = explode('/', $value['date']);
if (count($m) === 3) {
$year = $m[stripos($this->dateFormat, 'y') + 1];
$month = $m[stripos($this->dateFormat, 'm') + 1];
$day = $m[stripos($this->dateFormat, 'd') + 1];
} else {
$year = null;
$month = null;
$day = null;
}
}
}
// Check validity
if (!$year || !$month || !$day) {
$this->addError('Please select a date from the calendar.');
return false;
}
if ($month < 1 || $month > 12) {
$this->addError('The month is not right');
return false;
}
if ($day < 1 || $day > 31) {
$this->addError('the day is not right');
return false;
}
$dateArr['day'] = $day;
$dateArr['month'] = $month;
$dateArr['year'] = $year;
$this->setValue($dateArr);
$value = $this->getValue();
return parent::isValid($value, $context);
}
示例12: isValid
/**
* Is the value provided valid?
*
* Autoregisters InArray validator if necessary.
*
* @param string $value
* @param mixed $context
* @return bool
*/
public function isValid($value, $context = null)
{
if ($this->registerInArrayValidator()) {
if (!$this->getValidator('InArray')) {
$options = $this->getMultiOptions();
$this->addValidator('InArray', true, array(array_keys($options)));
}
}
return parent::isValid($value, $context);
}