How do I get the contents of a Summernote text area?

530 views
Skip to first unread message

Sharon Gilmore

unread,
Mar 6, 2014, 11:37:29 AM3/6/14
to bootstr...@googlegroups.com
I'm very new to Bootstrap and am trying to set up a simple form (using php).  I'm using Summernote, as it's built in (normally I would have used CKEditor or something like that).  So, I create the form, and try to submit it, but when I do, the content I entered in the Summernote boxes is missing.

I'm having trouble finding any help online (a few of the pages I found wouldn't load), so wondered whether anyone here could help me. Is there something I have to do to get the Summernote textarea data to post along with the regular text fields?

Thanks in advance for any help you're able to give.

LightDot

unread,
Mar 6, 2014, 11:56:05 AM3/6/14
to bootstr...@googlegroups.com
Summernote is a WYSWYG text editor, a separate project from Bootstrap. Your problem sounds like a php / form issue and it's really hard to say whats wrong, without seeing the code. Could be any number of things.

Regards

Sharon Gilmore

unread,
Mar 8, 2014, 9:34:07 AM3/8/14
to bootstr...@googlegroups.com
Ok. Below I've posted what I have.  It's really long, but the bit in italics is what Summernote added in, so it's probably standard stuff.

It looks to me like a standard form with a text editor added in. But when I go to the 'adminadd' action, and get it to dump to POSTed array, the 'Address' field of the 'data' is just empty.

I don't really even know where to start - is there something you have to do to get Summernote to pass the data through?  Can anyone even link me to some documentation on this?  I haven't been able to find anything that helps - the link from the Summernote documentation to a php example isn't working for me.

<form action="adminadd" id="RetailerAdminaddForm" enctype="multipart/form-data" method="post" accept-charset="utf-8">
    <input name="_method" value="POST" type="hidden">
    <div class="form-group">
        <label for="RetailerName">Business Name</label>
        <input name="data[Retailer][name]" id="RetailerName" type="text">
    </div>
    <div class="form-group">
        <label for="RetailerAddress" class="control-label col-md-4">Address</label>
        <input style="display: none;" name="data[Retailer][address]" class="summernote col-md-8 form-control" id="RetailerAddress" type="text">
        <div class="note-editor">
            <div class="note-dialog">
                <div class="note-image-dialog modal" aria-hidden="false">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" tabindex="-1">×</button>
                                <h4>Insert Image</h4>
                            </div>
                            <div class="modal-body">
                                <div class="row-fluid">
                                    <div class="note-dropzone span12">Drag an image here</div>
                                    <div>or if you prefer...</div>
                                    <input class="note-image-input" type="file">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="note-link-dialog modal" aria-hidden="false">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" tabindex="-1">×</button>
                                <h4>Edit Link</h4>
                            </div>
                            <div class="modal-body">
                                <div class="row-fluid">
                                    <div class="form-group">
                                        <label>Text to display</label>
                                        <span class="note-link-text form-control input-xlarge uneditable-input"></span>
                                    </div>
                                    <div class="form-group">
                                        <label>To what URL should this link go?</label>
                                        <input class="note-link-url form-control span12" type="text">
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button href="#" class="btn btn-primary note-link-btn disabled" disabled="disabled">Link</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="note-help-dialog modal fade" aria-hidden="false">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-body">
                                <div class="modal-background">
                                    <a class="modal-close pull-right" data-dismiss="modal" aria-hidden="true" tabindex="-1">Close</a>
                                    <div class="title">Keyboard shortcuts</div>
                                    <table class="note-shortcut-layout"><tbody><tr><td><table class="note-shortcut"><thead><tr><th></th><th>Action</th></tr></thead><tbody><tr><td>? + Z</td><td>Undo</td></tr><tr><td>? + ? + Z</td><td>Redo</td></tr><tr><td>? + ]</td><td>Indent</td></tr><tr><td>? + [</td><td>Outdent</td></tr><tr><td>? + K</td><td>Insert Link</td></tr><tr><td>? + ENTER</td><td>Insert Horizontal Rule</td></tr></tbody></table></td><td><table class="note-shortcut"><thead><tr><th></th><th>Text formatting</th></tr></thead><tbody><tr><td>? + B</td><td>Toggle Bold</td></tr><tr><td>? + I</td><td>Toggle Italic</td></tr><tr><td>? + U</td><td>Toggle Underline</td></tr><tr><td>? + ? + S</td><td>Toggle Strike</td></tr><tr><td>? + \</td><td>Remove Font Style</td></tr></tbody></table></td></tr><tr><td><table class="note-shortcut"><thead><tr><th></th><th>Document Style</th></tr></thead><tbody><tr><td>? + NUM0</td><td>Normal Text</td></tr><tr><td>? + NUM1</td><td>Heading 1</td></tr><tr><td>? + NUM2</td><td>Heading 2</td></tr><tr><td>? + NUM3</td><td>Heading 3</td></tr><tr><td>? + NUM4</td><td>Heading 4</td></tr><tr><td>? + NUM5</td><td>Heading 5</td></tr><tr><td>? + NUM6</td><td>Heading 6</td></tr></tbody></table></td><td><table class="note-shortcut"><thead><tr><th></th><th>Paragraph formatting</th></tr></thead><tbody><tr><td>? + ? + L</td><td>Align Left</td></tr><tr><td>? + ? + E</td><td>Align Center</td></tr><tr><td>? + ? + R</td><td>Align Right</td></tr><tr><td>? + ? + J</td><td>Justify Full</td></tr><tr><td>? + ? + NUM7</td><td>Ordered List</td></tr><tr><td>? + ? + NUM8</td><td>Unordered List</td></tr></tbody></table></td></tr></tbody></table>
                                    <p class="text-center"><a href="//hackerwins.github.io/summernote/" target="_blank">Summernote v0.3</a> · <a href="//github.com/HackerWins/summernote" target="_blank">Project</a> · <a href="//github.com/HackerWins/summernote/issues" target="_blank">Issues</a></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="note-handle">
                <div style="display: none;" class="note-control-selection"><div class="note-control-selection-bg"></div><div class="note-control-holder note-control-nw"></div><div class="note-control-holder note-control-ne"></div><div class="note-control-holder note-control-sw"></div><div class="note-control-sizing note-control-se"></div><div class="note-control-selection-info"></div></div>
            </div>
            <div class="note-popover">
                <div class="note-link-popover popover bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-link-content"><a href="http://www.google.com" target="_blank">www.google.com</a>&nbsp;&nbsp;<div class="note-insert btn-group"><button data-original-title="Edit" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="showLinkDialog" tabindex="-1"><i class="fa fa-edit"></i></button><button data-original-title="Unlink" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="unlink" tabindex="-1"><i class="fa fa-unlink"></i></button></div></div></div><div class="note-image-popover popover bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-image-content"><div class="btn-group"><button data-original-title="Resize Full" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="resize" data-value="1" tabindex="-1"><i class="fa fa-resize-full"></i></button><button data-original-title="Resize Half" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="resize" data-value="0.5" tabindex="-1">½</button><button data-original-title="Resize Thrid" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="resize" data-value="0.33" tabindex="-1">?</button><button data-original-title="Resize Quarter" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="resize" data-value="0.25" tabindex="-1">¼</button></div><div class="btn-group"><button data-original-title="Float Left" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="float" data-value="left" tabindex="-1"><i class="fa fa-align-left"></i></button><button data-original-title="Float Right" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="float" data-value="right" tabindex="-1"><i class="fa fa-align-right"></i></button><button data-original-title="Float None" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-event="float" data-value="none" tabindex="-1"><i class="fa fa-reorder"></i></button></div></div></div>
            </div>
            <div class="note-toolbar btn-toolbar">
                <div class="note-style btn-group"><button data-original-title="Bold (Ctrl+B)" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-shortcut="Ctrl+B" data-mac-shortcut="?+B" data-event="bold" tabindex="-1"><i class="fa fa-bold"></i></button><button data-original-title="Italic (Ctrl+I)" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-shortcut="Ctrl+I" data-mac-shortcut="?+I" data-event="italic" tabindex="-1"><i class="fa fa-italic"></i></button><button data-original-title="Underline (Ctrl+U)" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-shortcut="Ctrl+U" data-mac-shortcut="?+U" data-event="underline" tabindex="-1"><i class="fa fa-underline"></i></button><button data-original-title="Remove Font Style (Ctrl+\)" type="button" class="btn btn-default-outline btn-sm btn-small" title="" data-shortcut="Ctrl+\" data-mac-shortcut="?+\" data-event="removeFormat" tabindex="-1"><i class="fa fa-eraser"></i></button></div>
            </div>
            <div style="height: 140px;" class="note-editable" contenteditable="true">123 Retail Street<br>Shoptown<br></div>
            <div class="note-statusbar"><div class="note-resizebar"><div class="note-fa fa-bar"></div><div class="note-fa fa-bar"></div><div class="note-fa fa-bar"></div></div></div>

        </div>
    </div>
    <input class="btn btn-primary" value="Add Retailer" type="submit"></input>
</form>
Reply all
Reply to author
Forward
0 new messages