[Solar-talk] inList

Paul M Jones pmjones at solarphp.com
Sun Jun 18 06:50:36 PDT 2006


Hi Jeff,

Sorry for the long delay (6 weeks +) in following up.  Did we ever  
resolve this?

-- pmj



On Apr 27, 2006, at 12:06 PM, Jeff Surgeson wrote:

>>> Just a quick one about lists in data models, I have to do the
>>> following to get
>>> my form to validate a list array.
>>>
>>> $this->_col['book_feature'] = array(
>>>     'type'      => 'varchar',
>>>     'size'      => 32,
>>>     'require'   => true,
>>>     'default'   => 'None',
>>>     'valid' => array(
>>>         'inList',
>>>         'VALID_LIST',
>>>         array(
>>>             'None'	=> 'None',
>>>             'Home'	=> 'Home',
>>>             'Left'	=> 'Left',
>>>             'Right'   => 'Right',
>>>             'Search'	=> 'Search',
>>>         )
>>>     ),
>>> );
>>>
>>> If I do not specify am ass array it validates against the numerical
>>> key, is
>>> this normal?
>>
>> Hm, that doesn't sound right.  The inList() validation should
>> validate against the array values, and inKeys() should validate
>> against the array keys.  Are you getting the error at the form level,
>> or at the table level?
>
> At the form level, form does not validate. It seems to me that the  
> inList() is
> acting like inKeys() and unless it has both a key and value it  
> validates
> against the key and not the value.
>
>> Generally, I prefer inKeys() instead of inList() for tables and
>> forms; the key goes to the database, and the value is the displayed
>> value in the form.
>
> Never used it, I will try it.
>
>> However, I can see that I need to make Solar_Form_Load_Table a little
>> smarter in this regard, so that inList() validations take their form
>> values from the array values, and leave inKeys() so that it takes the
>> form values from the array keys.
>
> -- 
> Jeff Surgeson



--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.   <http://solarphp.com>

Savant: The simple, elegant, and powerful solution for
templates in PHP.   <http://phpsavant.com>




More information about the solar-talk mailing list