简体   繁体   中英

fcbkcomplete does not post

I want to populate the recipients field of a message form using FCBKComplete. The client-side works fine. FCBKComplete gets the options and writes the selected one into the recipients field. But when the form is posted, the POST data does not have the values in the recipients field.

The server-side is Django:

def recipients_autocomplete(request):
    q = request.GET.get('tag')
    dump = ''
    if q:
        users = User.objects.filter(username__startswith=q)
        results = [{"key": u.username, "value": u.username} for u in users]
        dump = json.dumps(results)
    return HttpResponse(dump, mimetype="text/plain")

The recipients is empty in the request.POST dictionary:

{...
 u'recipients[]': [u'']
 ...}

How can I can get the values in the autocompleted field?

Thanks.

The problem was that in my Django form the recipients is a CharField but fcbkComplete expects a select field. I changed the type of recipients in the form definition to ChoiceField and now the values are POSTed.

Another thing is the [] appended to the attribute name. To avoid that, I used this patch: https://github.com/eeabed/FCBKcomplete/commit/00183fbd83283cf05b3c9de02e076201623975dd

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM