
    WeIiQ                     J    d dl mZ ddlmZ ddlmZ dZ G d de          Zd	S )
    )unset_value   )widgets   )Field)	FormFieldc                        e Zd ZdZ ej                    Z	 d fd	ZedfdZ	ddZ
d Zd	 Zd
 Zd Zed             Zed             Z xZS )r   a-  
    Encapsulate a form as a field in another form.

    :param form_class:
        A subclass of Form that will be encapsulated.
    :param separator:
        A string which will be suffixed to this field's name to create the
        prefix to enclosed fields. The default is fine for most uses.
    N-c                      t                      j        ||fi | || _        || _        d | _        | j        rt          d          |rt          d          d S )NzGFormField cannot take filters, as the encapsulated data is not mutable.zTFormField does not accept any validators. Instead, define them on the enclosed form.)super__init__
form_class	separator_objfilters	TypeError)selfr   label
validatorsr   kwargs	__class__s         X/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/wtforms/fields/form.pyr   zFormField.__init__   s     	
55f555$"	< 	(    	5  	 	    c                 `   |rt          d          |t          u r4	 |                                 }n# t           $ r
 | j        }Y nw xY w|| _        || _        | j        | j        z   }t          |t                    r | j	        d||d|| _
        d S | 	                    |||          | _
        d S )NzFFormField cannot take filters, as the encapsulateddata is not mutable.)formdataprefix)r   objr    )r   r   defaultr   object_datanamer   
isinstancedictr   form)r   r   dataextra_filtersr   s        r   processzFormField.process(   s     	'  
 ;$||~~ $ $ $|$DIT^+dD!! 	T'Q&QQDQQDIIItFSSDIIIs   1 AAr   c                 V    |rt          d          | j                                        S )NzWFormField does not accept in-line validators, as it gets errors from the enclosed form.)r   r$   validate)r   r$   extra_validatorss      r   r)   zFormField.validate>   s7     	7   y!!###r   c                     t          ||d           }|| j        t          d          | j        }| j                            |           t          |||           d S )NzZpopulate_obj: cannot find a value to populate from the provided obj or input data/defaults)getattrr   r   r$   populate_objsetattr)r   r   r!   	candidates       r   r-   zFormField.populate_objF   so    Ct,,	y ?   	I	y)))T9%%%%%r   c                 *    t          | j                  S N)iterr$   r   s    r   __iter__zFormField.__iter__S   s    DIr   c                     | j         |         S r1   )r$   r   r!   s     r   __getitem__zFormField.__getitem__V   s    yr   c                 ,    t          | j        |          S r1   )r,   r$   r6   s     r   __getattr__zFormField.__getattr__Y   s    ty$'''r   c                     | j         j        S r1   )r$   r%   r3   s    r   r%   zFormField.data\   s    y~r   c                     | j         j        S r1   )r$   errorsr3   s    r   r<   zFormField.errors`   s    yr   )NNr
   )r   )__name__
__module____qualname____doc__r   TableWidgetwidgetr   r   r'   r)   r-   r4   r7   r9   propertyr%   r<   __classcell__)r   s   @r   r   r   	   s         !W ""F BE     $ &1 T T T T,$ $ $ $& & &    ( ( (   X     X         r   r   N)wtforms.utilsr    r   corer   __all__r   r   r   r   <module>rI      s~    % % % % % %            
Y  Y  Y  Y  Y  Y  Y  Y  Y  Y r   