
    +hP                     B    d dl mZ ddlmZ ddlmZ dZ G d de      Zy	)
   )widgets   )Field    )unset_value)	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.
    Nc                     t        |   ||fi | || _        || _        d | _        | j
                  rt        d      |rt        d      y )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         F/var/www/html/venv/lib/python3.12/site-packages/wtforms/fields/form.pyr   zFormField.__init__   sc     	
5f5$"	<<(  5      c                 \   |rt        d      |t        u r	 | j                         }|| _        || _        | j
                  | j                  z   }t        |t              r | j                  d||d|| _
        y | j                  |||      | _
        y # t         $ r | j                  }Y w xY w)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!'Q&QDQDItFSDI  $||$s   B B+*B+c                 P    |rt        d      | j                  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=   s,    7  yy!!##r   c                     t        ||d       }|#| j                  t        d      | j                  }| j                  j	                  |       t        |||       y )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_objE   s[    Ct,	yy ?  		I		y)T9%r   c                 ,    t        | j                        S N)iterr#   r   s    r   __iter__zFormField.__iter__R   s    DIIr   c                      | j                   |   S r0   )r#   r   r    s     r   __getitem__zFormField.__getitem__U   s    yyr   c                 .    t        | j                  |      S r0   )r+   r#   r5   s     r   __getattr__zFormField.__getattr__X   s    tyy$''r   c                 .    | j                   j                  S r0   )r#   r$   r2   s    r   r$   zFormField.data[   s    yy~~r   c                 .    | j                   j                  S r0   )r#   errorsr2   s    r   r;   zFormField.errors_   s    yyr   )NN-)r   )__name__
__module____qualname____doc__r   TableWidgetwidgetr   r   r&   r(   r,   r3   r6   r8   propertyr$   r;   __classcell__)r   s   @r   r   r      st     !W  "F BE$ &1 T,$&(      r   r   N) r   corer   wtforms.utilsr   __all__r   r   r   r   <module>rI      s!      %
Y  Y r   