Пример #1
0
 public function onPreRender($param)
 {
     parent::onPreRender($param);
     $cs = $this->Page->getClientScript();
     $cs->registerPradoScript('validator');
     // communicate validation status to the client side
     $value = $this->_isvalid === false ? '0' : '1';
     $cs->registerHiddenField($this->getClientID() . '_1', $value);
     // update validator display
     if ($control = $this->getValidationTarget()) {
         $fn = 'captchaUpdateValidatorStatus_' . $this->getClientID();
         // check if we need to request a new captcha too
         if ($this->Page->IsCallback) {
             if ($control->getVisible(true)) {
                 if (!is_null($this->_isvalid)) {
                     // if the response has been tested and we reach the pre-render phase
                     // then we need to regenerate the token, because it won't test positive
                     // anymore, even if solves correctly
                     $control->regenerateToken();
                 }
             }
         }
         $cs->registerEndScript($this->getClientID() . '::validate', implode(' ', array('function ' . $fn . '(valid)', '{', '  jQuery(' . TJavaScript::quoteString('#' . $this->getClientID() . '_1') . ').val(valid);', '  Prado.Validation.validateControl(' . TJavaScript::quoteString($control->ClientID) . '); ', '}', '', $this->Page->IsCallback ? $fn . '(' . $value . ');' : '', '', 'jQuery("#' . $control->getClientID() . '").on("keyup", ' . TJavaScript::quoteString('#' . $control->getResponseFieldName()) . ', function() { ', $fn . '("1");', '});')));
     }
 }
Пример #2
0
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $options['DataType'] = $this->getDataType();
     if (($dateFormat = $this->getDateFormat()) !== '') {
         $options['DateFormat'] = $dateFormat;
     }
     return $options;
 }
Пример #3
0
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $control = $this->getValidationTarget();
     if (!$control instanceof TListControl) {
         throw new TConfigurationException('listcontrolvalidator_invalid_control', $this->getID(), $this->getControlToValidate(), get_class($control));
     }
     $min = $this->getMinSelection();
     $max = $this->getMaxSelection();
     if ($min !== -1) {
         $options['Min'] = $min;
     }
     if ($max !== -1) {
         $options['Max'] = $max;
     }
     $required = $this->getRequiredSelections();
     if (strlen($required) > 0) {
         $options['Required'] = $required;
     }
     $options['TotalItems'] = $control->getItemCount();
     return $options;
 }
Пример #4
0
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $control = $this->findCaptchaControl();
     if ($control->getCaseSensitive()) {
         $options['TokenHash'] = $this->generateTokenHash($control->getToken());
         $options['CaseSensitive'] = true;
     } else {
         $options['TokenHash'] = $this->generateTokenHash(strtoupper($control->getToken()));
         $options['CaseSensitive'] = false;
     }
     return $options;
 }
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $options['ValidationExpression'] = $this->getRegularExpression();
     $options['PatternModifiers'] = $this->getClientSidePatternModifiers();
     return $options;
 }
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $options['InitialValue'] = $this->getInitialValue();
     $control = $this->getValidationTarget();
     if ($control instanceof TListControl) {
         $options['TotalItems'] = $control->getItemCount();
     }
     if ($control instanceof TRadioButton && strlen($control->getGroupName()) > 0) {
         $options['GroupName'] = $control->getGroupName();
     }
     return $options;
 }
 /**
  * Ensure that the ID attribute is rendered and registers the javascript code
  * for initializing the active control.
  */
 protected function addAttributesToRender($writer)
 {
     parent::addAttributesToRender($writer);
     TBaseValidator::registerClientScriptValidator();
 }
Пример #8
0
 /**
  * Only register the client-side validator if
  * {@link setClientValidationFunction ClientValidationFunction} is set.
  */
 protected function registerClientScriptValidator()
 {
     if ($this->getClientValidationFunction() !== '') {
         parent::registerClientScriptValidator();
     }
 }
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $options['MinValue'] = $this->getMinValue();
     $options['MaxValue'] = $this->getMaxValue();
     $options['DataType'] = $this->getDataType();
     $options['StrictComparison'] = $this->getStrictComparison();
     if (($dateFormat = $this->getDateFormat()) !== '') {
         $options['DateFormat'] = $dateFormat;
     }
     return $options;
 }
Пример #10
0
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     if (($name = $this->getControlToCompare()) !== '') {
         if (($control = $this->findControl($name)) !== null) {
             $options['ControlToCompare'] = $control->getClientID();
         }
     }
     if (($value = $this->getValueToCompare()) !== '') {
         $options['ValueToCompare'] = $value;
     }
     if (($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) {
         $options['Operator'] = $operator;
     }
     $options['DataType'] = $this->getDataType();
     if (($dateFormat = $this->getDateFormat()) !== '') {
         $options['DateFormat'] = $dateFormat;
     }
     return $options;
 }
 /**
  * Returns an array of javascript validator options.
  * @return array javascript validator options.
  */
 protected function getClientScriptOptions()
 {
     $options = parent::getClientScriptOptions();
     $options['ControlMask'] = $this->ControlMask;
     $options['Fillspace'] = $this->Fillspace;
     return $options;
 }