Author: Krapulator
Date: 2010-02-19 07:18:30 +0100 (Fri, 19 Feb 2010)
New Revision: 28135
Modified:
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/actions/actions.class.php
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/templates/indexSuccess.php
Log:
Continued work on new, updated version.
Modified:
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
===================================================================
---
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
2010-02-19 01:17:42 UTC (rev 28134)
+++
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
2010-02-19 06:18:30 UTC (rev 28135)
@@ -94,11 +94,12 @@
public function processValidationRules($name, sfForm $form, $is_embedded =
false)
{
+ //dev::pr($form->getValidatorSchema()->getFields(), true);
foreach($form->getValidatorSchema()->getFields() as $fieldname =>
$objField)
{
// ignore the csrf field
- if($name == '_csrf_token') continue;
+ if($fieldname == '_csrf_token') continue;
// get the correct html "name" for this field
$validation_name = $this->createValidationName($name,
$fieldname, $is_embedded);
@@ -109,7 +110,7 @@
}
- private function processRules($validation_name, sfWidget $objField)
+ private function processRules($validation_name, sfValidatorBase $objField)
{
$field_options = $objField->getOptions();
@@ -152,7 +153,7 @@
}
}
- private function processMessages($validation_name, sfWidget $objField)
+ private function processMessages($validation_name, sfValidatorBase
$objField)
{
foreach($objField->getOptions() as $key => $val)
{
@@ -160,7 +161,7 @@
}
}
- private function parseMessageKey($key, sfWidget $objField)
+ private function parseMessageKey($key, sfValidatorBase $objField)
{
$class = get_class($objField);
if(isset(self::$widgets[$class]['keymap'][$key]))
@@ -174,7 +175,7 @@
return $key;
}
- private function outputMessageKey($key, sfWidget $objField)
+ private function outputMessageKey($key, sfValidatorBase $objField)
{
$class = get_class($objField);
if(isset(self::$widgets[$class]['msgmap'][$key]))
@@ -188,7 +189,7 @@
return $key;
}
- private function parseMessageVal($key, sfWidget $objField)
+ private function parseMessageVal($key, sfValidatorBase $objField)
{
$field_options = $objField->getOptions();
@@ -197,7 +198,7 @@
// if the field options for this item is empty, don't include it
if(strlen($field_options[$key]) == 0) return "";
- if((isset($messages[$key]) ||
isset($messages[$this->parseMessageKey($key)])) &&
isset($this->rules[$validation_name])) return "";
+ if((isset($messages[$key]) ||
isset($messages[$this->parseMessageKey($key, $objField)])) &&
isset($this->rules[$validation_name])) return "";
// find the actual error message
$mapped_key = $this->parseMessageKey($key, $objField);
Modified:
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/actions/actions.class.php
===================================================================
---
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/actions/actions.class.php
2010-02-19 01:17:42 UTC (rev 28134)
+++
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/actions/actions.class.php
2010-02-19 06:18:30 UTC (rev 28135)
@@ -12,6 +12,10 @@
// and it is really a symfony form
$this->forward404Unless($this->isValidSfFormName($form));
+ // errors have to be disabled because any kind of warning message will
break
+ // the outputted javascript
+ error_reporting('E_NONE');
+
// create an instance of the sfJqueryFormValidationRules object
$this->sf_jq_rules = new sfJqueryFormValidationRules(new $form);
Modified:
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/templates/indexSuccess.php
===================================================================
---
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/templates/indexSuccess.php
2010-02-19 01:17:42 UTC (rev 28134)
+++
plugins/sfJqueryFormValidationPlugin/modules/sfJqueryFormVal/templates/indexSuccess.php
2010-02-19 06:18:30 UTC (rev 28135)
@@ -1,3 +1,5 @@
+<?php $sf_jq_rules = $sf_data->getRaw('sf_jq_rules') ?>
+
jQuery(function($){
$('#<?php echo $sf_jq_rules->getFirstFieldHtmlId()
?>').parents('form').validate({
@@ -36,85 +38,4 @@
return this.optional(element) || regexp.test(value);
},
"Invalid."
-);
-
-<?php
-function json_format($json)
-{
-
- $tab = " ";
- $new_json = "";
- $indent_level = 0;
- $in_string = false;
-
- $json_obj = json_decode($json);
-
- if($json_obj === false)
- return false;
-
- $json = json_encode($json_obj);
- $len = strlen($json);
-
- for($c = 0; $c < $len; $c++)
- {
- $char = $json[$c];
- switch($char)
- {
- case '{':
- case '[':
- if(!$in_string)
- {
- $new_json .= $char . "\n" . str_repeat($tab,
$indent_level+1);
- $indent_level++;
- }
- else
- {
- $new_json .= $char;
- }
- break;
- case '}':
- case ']':
- if(!$in_string)
- {
- $indent_level--;
- $new_json .= "\n" . str_repeat($tab, $indent_level) .
$char;
- }
- else
- {
- $new_json .= $char;
- }
- break;
- case ',':
- if(!$in_string)
- {
- $new_json .= ",\n" . str_repeat($tab, $indent_level);
- }
- else
- {
- $new_json .= $char;
- }
- break;
- case ':':
- if(!$in_string)
- {
- $new_json .= ": ";
- }
- else
- {
- $new_json .= $char;
- }
- break;
- case '"':
- if($c > 0 && $json[$c-1] != '\\')
- {
- $in_string = !$in_string;
- }
- default:
- $new_json .= $char;
- break;
- }
- }
-
- return $new_json;
-}
-?>
\ No newline at end of file
+);
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.