from django.shortcuts import render
from basicapp import forms
# Create your views here.

def index(request):
    return render(request,'basicapp/index.html')

def form_name_view(request):
    form = forms.FormName
    #this is not an instance

    # grab the data post by user
    if request.method == 'POST':
        form = forms.FormName(request.POST)
        #this is an instance,(request.POST) is a complex attribute package
        if form.is_valid():
            #DO SOMETHING CODE
            print('VALIDATION SUCCESS!')
            print('NAME: '+form.cleaned_data['name'])
            print('EMAIL: '+form.cleaned_data['email'])
            print('TEXT: '+form.cleaned_data['text'])


    return render(request,'basicapp/form_page.html',{'form':form})