Custom Edit Rules

QuestionsCustom Edit Rules
Kelvin asked 10 years ago

Dear Sir/Madam,

Refer to http://www.phpgrid.org/docs/#column-options, the Edit Rules, is the <script> a javascript or php script? If php script, why using the <script>… </script>. If javascript, why it is coded in php script?

$col["editrules"] = array("custom"=>true,
"custom_func"=>"function(val,label){return my_validation(val,label);}");

<script>
function my_validation(value,label)
{
if (value < 100)
return [true,""];
else
return [false,label+" should be less than 100"];
}
</script>

3 Answers
Abu Ghufran answered 10 years ago

Hello,

It's basically javascript, and it is used in PHP (as text string) to invoke at proper place inside library.

Cristian Engelmann answered 9 years ago

Hi,

similar before example. But I want three element. How can I to send data field (val2)?.

$col = array();
$col["title"] = "buy"; //this is val2
$col["name"] = "buy";
$col["width"] = "10";
$col["align"] = "right"; // this column is not editable
$col["search"] = false; // this column is not searchable
$cols[] = $col;

$col = array();
$col["title"] = "total";
$col["name"] = "total";
$col["width"] = "10";
$col["align"] = "right";
$col["search"] = false;
$col["editable"] = true;
$col["editrules"] = array("custom"=>true,
"custom_func"=>"function(val,val2,label){return my_validation(val,val2,label);}");
$cols[] = $col;

<script>
function my_validation(value,value2,label)
{
if (value < value2) // if (value < 100) *****
return [true,""];
else
return [false,label+" should be less than 100"];
}
</script>

Abu Ghufran answered 9 years ago

Refer editing/js-validation-form.php demo. It allows complete form fields to be validation at once.

PS: Please send your query once, duplicates (direct email / forum question) creates confusion in answering.

Your Answer

16 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?