Added Valid and enabled Form::select sorting
This commit is contained in:
parent
1ec370f07a
commit
c132357630
4
classes/Valid.php
Normal file
4
classes/Valid.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
class Valid extends lnApp_Valid {}
|
||||
?>
|
@ -81,6 +81,11 @@ abstract class lnApp_Form extends Kohana_Form {
|
||||
unset($attributes['oneonly']);
|
||||
}
|
||||
|
||||
if (isset($attributes['sort']) AND $attributes['sort']) {
|
||||
asort($options);
|
||||
unset($attributes['sort']);
|
||||
}
|
||||
|
||||
return sprintf(static::_controlgroup($name,$attributes),parent::select($name,$options,$selected,$attributes));
|
||||
}
|
||||
|
||||
|
25
classes/lnApp/Valid.php
Normal file
25
classes/lnApp/Valid.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends Kohana's Valid
|
||||
*
|
||||
* @package lnApp
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class lnApp_Valid extends Kohana_Valid {
|
||||
/**
|
||||
* Checks that a value is not equal to another list of values
|
||||
*
|
||||
* @param string $value value
|
||||
* @param array $list List of Values that shouldnt equal
|
||||
* @return boolean
|
||||
*/
|
||||
public static function not_equal($value, array $list)
|
||||
{
|
||||
return ! in_array($value,$list);
|
||||
}
|
||||
}
|
||||
?>
|
5
messages/validation.php
Normal file
5
messages/validation.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'not_equal' => ':field cannot have that value, or it was not specified!',
|
||||
);
|
Reference in New Issue
Block a user