Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
options.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Form
5  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
6  * @license GNU General Public License version 2 or later; see LICENSE.txt
7  */
8 
9 defined('JPATH_PLATFORM') or die;
10 
11 /**
12  * Form Rule class for the Joomla Platform.
13  * Requires the value entered be one of the options in a field of type="list"
14  *
15  * @package Joomla.Platform
16  * @subpackage Form
17  * @since 11.1
18  */
20 {
21  /**
22  * Method to test the value.
23  *
24  * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
25  * @param mixed $value The form field value to validate.
26  * @param string $group The field name group control value. This acts as as an array container for the field.
27  * For example if the field has name="foo" and the group value is set to "bar" then the
28  * full field name would end up being "bar[foo]".
29  * @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
30  * @param JForm $form The form object for which the field is being tested.
31  *
32  * @return boolean True if the value is valid, false otherwise.
33  *
34  * @since 11.1
35  */
36  public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
37  {
38  // Check each value and return true if we get a match
39  foreach ($element->option as $option)
40  {
41  if ($value == (string) $option->attributes()->value)
42  {
43  return true;
44  }
45  }
46  return false;
47  }
48 }