
^Q\o                 @   sF   d  Z  d d l m Z Gd d   d e  Z Gd d   d e  Z d S)z$Select2 field implementation module.    )ChoiceFieldc            	       s:   e  Z d  Z d Z d d d d d d   f d d  Z   S)Select2ListChoiceFieldzAllows a list of values to be used with a ChoiceField.

    Avoids unusual things that can happen if Select2ListView is used for
    a form where the text and value for choices are not the same.
    NT c       
         s     p	 g    t     r-   f d d   }	 n d d     D }	 t t |   j d |	 d | d | d | d	 | d
 | | |  d S)zUse a list to generate choices in a ChoiceField.

        .. py:param choice_list: The list to use to generate choices or a
        function that returns a list.
        c                  s   d d       D S)Nc             S   s   g  |  ] } | | f  q S r   ).0choicer   r   G/var/www/dbchiro/venv/lib/python3.4/site-packages/dal_select2/fields.py
<listcomp>   s   	 zESelect2ListChoiceField.__init__.<locals>.<lambda>.<locals>.<listcomp>r   r   )choice_listr   r   <lambda>   s    z1Select2ListChoiceField.__init__.<locals>.<lambda>c             S   s   g  |  ] } | | f  q Sr   r   )r   r   r   r   r   r	      s   	 z3Select2ListChoiceField.__init__.<locals>.<listcomp>choicesrequiredwidgetlabelinitial	help_textN)callablesuperr   __init__)
selfr
   r   r   r   r   r   argskwargsr   )	__class__)r
   r   r      s    zSelect2ListChoiceField.__init__)__name__
__module____qualname____doc__r   r   r   )r   r   r      s   	r   c                   s(   e  Z d  Z d Z   f d d   Z   S)Select2ListCreateChoiceFieldz5Skips validation of choices so any value can be used.c                s   t  t |   j |  d S)z,Do not validate choices but check for empty.N)r   r   validate)r   value)r   r   r   r   %   s    z%Select2ListCreateChoiceField.validate)r   r   r   r   r   r   r   )r   r   r   "   s   r   N)r   Zdjango.formsr   r   r   r   r   r   r   <module>   s   