Hi Сергей Ф,

It worked now!!! \o/  

But I have a question... in this case why do I need to send "None" in "
get_form_kwargs" and why should I use the  "super(ContactForm2, 
self).__init__(*args, **kwargs)" after the init? 

Thank you very much for your help!!

Leandro
*
*
On Tuesday, July 10, 2012 1:45:38 PM UTC+2, Сергей Ф. wrote:
>
> You can try to override get_form_kwargs method
>
> def get_form_kwargs(self, step):
>     if step == '1'
>         cleaned_data = self.get_cleaned_data_for_step('0') or {}
>         return {'sender': cleaned_data.get('sender', None)}
>     else:
>         return {}
>
> and in ContactForm2 override __init__ method with kwargs, for example:
>
> class ContactForm2(forms.Form):
>     def __init__(self, *args, **kwargs):
>         sender = kwargs.pop('sender', None)
>         if sender in ['ema...@example.com', ]:
>             # some actions
>         super(ContactForm2, self).__init__(*args, **kwargs)
>
>     message = forms.CharField(widget=forms.Textarea)
>
> I didn't try it myself, hope this will work)
>
> 2012/7/10 Leandro Alves <ldal...@gmail.com>
>
>> Hi,
>>
>> Yes... it is exactly with the form wizard that I'm trying to do it..
>>
>> But how can I "receive" these values inside my forms.py? This is what I 
>> couldn't find yet. 
>>
>> I want to be able use this values inside the ContactForm2 form. 
>>
>> Thanks for your help so far. 
>>
>> Leandro
>>
>>
>>
>> On Tuesday, July 10, 2012 12:56:39 PM UTC+2, Сергей Ф. wrote:
>>>
>>> Why not use Form Wizard from django.contrib.formtools.
>>> Look at https://docs.djangoproject.**com/en/dev/ref/contrib/**
>>> formtools/form-wizard/#**conditionally-view-skip-**specific-steps<https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/#conditionally-view-skip-specific-steps>
>>> Simply change show_message_form_condition method to something like
>>>
>>> def show_message_form_condition(wi**zard):
>>>     cleaned_data = wizard.get_cleaned_data_for_**step('0') or {}
>>>     return cleaned_data.get('sender', '') in ['adm...@example.com', 
>>> 'specialu...@example.com']
>>>
>>>
>>>
>>>
>>> 2012/7/10 Leandro Alves <ldal...@gmail.com>
>>>
>>>> Hi, 
>>>>
>>>> I'm new in Django and I'm struggling myself here to find out how to get 
>>>> the value of a field inside the forms.py. 
>>>> Yes, I did read the documentation, keep reading and searching on the 
>>>> internet... But please, could someone give a tip regarding this? 
>>>>
>>>> I just want to get/use the values of the fields from ContactForm1 into 
>>>> ContactForm2? Is that possible? 
>>>>
>>>> I know that in the views.py, we can get it from the "cleaned_data"... 
>>>> but how in the forms.py? 
>>>>
>>>>  from django import forms
>>>>  
>>>>  class ContactForm1(forms.Form):
>>>>      subject = forms.CharField(max_length=**100**)
>>>>      sender = forms.EmailField()
>>>>  
>>>>  class ContactForm2(forms.Form):
>>>>      message = forms.CharField(widget=forms.**T**extarea)
>>>>  
>>>>  For example I want to be able to use the value of the "sender" inside 
>>>> the ContactForm2, showing the message box just for some specific 
>>>> senders... 
>>>>  
>>>>  Please anyone with a simple tip? 
>>>>
>>>> Thanks in advance,
>>>>  
>>>>  Leandro 
>>>>  
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Django users" group.
>>>> To view this discussion on the web visit https://groups.google.com/d/**
>>>> msg/django-users/-/v_**d4gPDBOy4J<https://groups.google.com/d/msg/django-users/-/v_d4gPDBOy4J>
>>>> .
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> To unsubscribe from this group, send email to django-users+unsubscribe@
>>>> **googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>> .
>>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/uOZzfAUMgDgJ.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/I_nKu8OfgpgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to