开发者

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开发者_JAVA百科, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜