Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactor in new inline row required fail #7

Open
engrost opened this issue Sep 1, 2014 · 2 comments
Open

Reactor in new inline row required fail #7

engrost opened this issue Sep 1, 2014 · 2 comments

Comments

@engrost
Copy link

engrost commented Sep 1, 2014

Django 1.6.2
django-suit 0.2.4-0.2.9
django-suit-reactor 0.2

Scenario:
2 Models - parent and FK with SortableStackedInline in admin and reactor widget over field

class PageInline(SortableTabularInline):
    model = Page
    extra = 0
    fields = ('name','description','order')
    sortable = 'order'

    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name == 'description':
            kwargs['widget'] = RedactorWidget(editor_options={'lang': 'en'})
        return super(PageInline,self).formfield_for_dbfield(db_field,**kwargs)

How to recreate:

  • adding new inline in admin
  • fill 'description' into reactor widget
  • click save

Expected:
Save without any problems

Actual:
Getting error that 'description' is empty

  • looking at HTTP POST - the text value for description field is empty too.

Work Around:

  1. after first save you can fill in description and save without problems
  2. remove widget
@bigjust
Copy link

bigjust commented Oct 26, 2016

This is still an issue, and a rather glaring one

I'll investigate since this is an open bug with our integration, but any insight from the authors would be much appreciated

@mordonez-me
Copy link

mordonez-me commented Sep 17, 2017

The following code is a simple workaround for this situation:

$(function () {
        Suit.after_inline.register('my_unique_func_name', function(inline_prefix, row){
            $.each($(row).find('.redactor_box'), function(index, redactor_box){
                var script = $(redactor_box).parent().find("script").html()
                if(script.search("__prefix__") > -1){
                    $(redactor_box).find(".redactor_editor").remove()
                    $(redactor_box).find(".redactor_toolbar").remove()
                    $(redactor_box).removeClass("redactor_box")
                    var index = $(row).closest('.inline-related').index(".dynamic-" + inline_prefix)
                    eval(script.replace("__prefix__", index))
                }    
            })
            
        });
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants