Actions

Difference between revisions of "Overriding JFormRules"

From Joomla! Documentation

(Cleanup source a bit and add Needs review)
 
Line 1: Line 1:
<source lang="javascript">
+
{{review||Article needs structure and examples to be improved}}
[[File:To extend the rules that can be used by Joomla to validate form input, the following changes are needed:
+
To extend the rules that can be used by Joomla to validate form input, the following changes are needed:
  
 
== Step 1: Alter the controller ==
 
== Step 1: Alter the controller ==
Line 14: Line 14:
  
 
In the folder models/rules in the component add any rule file you want to use.
 
In the folder models/rules in the component add any rule file you want to use.
</source>
 
[[File:Example.jpg]]== Step 2: Add the rule files ==
 
  
In the folder models/rules in the component add any rule file you want to use.
+
[[File:Example.jpg]]
</source>
+
 
 
<gallery>
 
<gallery>
 
File:Example.jpg|Caption1
 
File:Example.jpg|Caption1

Latest revision as of 21:16, 14 June 2014

Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.

Reason: Article needs structure and examples to be improved


To extend the rules that can be used by Joomla to validate form input, the following changes are needed:

Step 1: Alter the controller

In the controller function add these lines:

$form   = $model->getForm();
$form->addRulePath(JPATH_COMPONENT.'/models/rules');

Step 2: Add the rule files

In the folder models/rules in the component add any rule file you want to use.

File:Example.jpg