5 class Char extends \Rsi\Fred\Controller\Widget{
31 $config = array_merge(parent::clientConfig(),$this->
get([self::NOTATION,self::TRANSFORM,self::REGEX,self::TRIM]));
32 if($this->suggest) $config[self::SUGGEST] =
true;
37 return $this->local->formatInt($value);
41 return $value && is_string($value) ? $value : null;
45 return $this->transform && !$this->
nothing($value) ? \Rsi\Str::transform($value,$this->transform) : $value;
49 return $this->trim ? trim($value,$this->trim ===
true ?
" \t\n\r" : $this->trim) : $value;
52 protected function checkMin($value,$index = null){
53 return !$this->min || (mb_strlen($value) >=
$this->min);
56 protected function checkMax($value,$index = null){
57 return !$this->max || (mb_strlen($value) <=
$this->max);
61 return !$this->regex || preg_match($this->regex,$value);
65 if(is_callable(
$suggest = $this->suggest))
70 elseif(!preg_match(
'/^(\\w+)\\.(\\w+)$/',
$suggest,$match))
72 elseif(($count = count(
$suggest = $this->db->record(
73 $this->db->limit($sql =
" 74 select distinct(`$match[2]`) from `$match[1]` 75 where `$match[2]` like :this 76 order by `$match[2]`",
79 [
'this' => $value = $this->params[
'this'] .
'%']
80 ))) < $this->suggestLimit)
$suggest = array_merge($suggest,$this->db->record(
81 $this->db->limit($sql,$this->suggestLimit - $count),
82 [
'this' =>
'_%' . $value]
85 $this->request->result = [
'suggest' =>
$suggest];
89 return array_merge(parent::getParams(),[
'this' => $this->request->this]);