Skip to content

Commit

Permalink
Added class origin tooltip for validation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreytgilbert committed Feb 17, 2013
1 parent 35c8658 commit 2634de4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
Expand Up @@ -206,15 +206,17 @@ public function handleRequest(){
$ReflechtionClass = new ReflectionClass('Valid'.$validator_type);
if(count($ReflechtionClass->getMethods()) > 0){
$these_methods = $ReflechtionClass->getMethods();
$actual_methods = array();

foreach($these_methods as $method){
$tmp_validator_type_methods[$method->name] = $method->class;
}
}

foreach($tmp_validator_type_methods as $the_method => $class_origin){
if(!in($the_method, array('__construct','cast','getData','getErrors', 'throwException'))){
$validator_type_methods['Valid'.$validator_type][] = $the_method;
//$validator_type_methods['Valid'.$validator_type][] = $the_method;
$validator_type_methods['Valid'.$validator_type][] = array($class_origin=>$the_method);

$Reflection = new ReflectionMethod($class_origin, $the_method);
if(count($Reflection->getParameters()) > 0){
$params = $Reflection->getParameters();
Expand Down Expand Up @@ -245,14 +247,30 @@ public function handleRequest(){
}

foreach($validator_type_methods as $validator_name => $validator_methods){
// pr($validator_methods);die;

$methods = array();
foreach($validator_methods as $validator_method_name){
// pr(__LINE__);
// pr($validator_name);
// pr($validator_method_name);
// Set the class origin
$validator_class_origin = $validator_name;
if(is_array($validator_method_name)){
$validator_class_origin = key($validator_method_name);
$validator_method_name = current($validator_method_name);
}
// pr('ME'.$validator_method_name);

if(isset($validator_type_method_arguments[$validator_name][$validator_method_name])
&& count($validator_type_method_arguments[$validator_name][$validator_method_name]) > 0){
$params = $validator_type_method_arguments[$validator_name][$validator_method_name];
// pr($params);
// pr('MEH'.$validator_method_name);
// pr($params);
$validator_method_parameters = array();
foreach($params as $param_name => $param_definition){
// pr($param_name);
// pr($param_definition);
$validator_method_parameters[] = array(
'parameter_name'=>$param_name,
'parameter_definition'=>$param_definition
Expand All @@ -264,9 +282,11 @@ public function handleRequest(){

$methods[] = array(
'method_name'=>$validator_method_name,
'class_origin'=>$validator_class_origin,
'parameters'=>$validator_method_parameters
);
}

$validators[] = array(
'validator_type'=>substr($validator_name,5,mb_strlen($validator_name)),
'methods'=>$methods
Expand Down
7 changes: 7 additions & 0 deletions www/js/Pages/DeveloperTools/FormBuilder.js
Expand Up @@ -117,6 +117,9 @@ require(
ValidatorList
));

$('#EditField .method_name').tooltip({placement:'right'});
$('#EditField .method_name').tooltip();

$('.parameters',this.self).hide();
},
'.methods change': function(element, jquery_event){
Expand All @@ -142,6 +145,10 @@ require(
ValidatorList
));


$('#AddField .method_name').tooltip({placement:'right'});
$('#AddField .method_name').tooltip();

$('.parameters',this.self).hide();
},
'.methods change': function(element, jquery_event){
Expand Down
Expand Up @@ -16,7 +16,7 @@
id="bv_{{validator_type}}_{{method_name}}"
name="FormBuilder[Validator][{{validator_type}}][{{method_name}}]"
value="{{method_name}}"
> {{method_name}}
> <span class="method_name" data-toggle="tooltip" title="A method of {{class_origin}}">{{method_name}}</span>
</label>
<div class="parameters">
{{#parameters}}
Expand Down
Expand Up @@ -16,7 +16,7 @@
id="ev_{{validator_type}}_{{method_name}}"
name="FormBuilder[Validator][{{validator_type}}][{{method_name}}]"
value="{{method_name}}"
> {{method_name}}
> <span class="method_name" data-toggle="tooltip" title="A method of {{class_origin}}">{{method_name}}</span>
</label>
<div class="parameters">
{{#parameters}}
Expand Down

0 comments on commit 2634de4

Please sign in to comment.