ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using File fields in Channel Form ?

October 15, 2013 3:39pm

Subscribe [3]
  • #1 / Oct 15, 2013 3:39pm

    Eric N

    28 posts

    I added a file field to a simple Channel Form and it doesn’t appear to be uploading the file or attaching it to the entry etc.

    Is there specific code that needs to be used other than just the field name? I can’t seem to find any documentation on how to actually use file fields with Channel Form so I’m not sure if I’m coding it correctly. Basically I’m using:

    <label for="copy">Image</label>
     <input type="file" id="image_1" name="image_1" />
     File size must be under 2MB

    image_1 being one of my channel’s file fields.

    Thanks for any help!

  • #2 / Oct 15, 2013 3:57pm

    Podzol

    80 posts

    When I use a file field in a channel form I just do this:

    {field:my-field-name}

    Usually works just fine.

    Also: Make certain that you have your file upload preferences set up right in the File Manager (Content section of CP) and the upload directory selected in your Channel Field. You may check the permissions on the upload directories, also.

    Hope this is some help.

  • #3 / Oct 16, 2013 10:06am

    Eric N

    28 posts

    Thanks for the reply!

    OK this just made it more strange.. but maybe this will make sense to you or someone else.

    I attached the screenshot of what I see when I use

    {field:file_field}

    It has a ghost file that doesn’t exist.. if I “remove” it, which most people will probably do that use this form, it doesn’t upload the file I chose.

    If I leave this mystery file alone, it uploads the file fine.

     

  • #4 / Oct 16, 2013 11:54am

    Eric N

    28 posts

    And now it wants to show the list of existing images in a drop down that wasn’t there before either! I think my EE has gone loopy… or maybe its time to go grab a coffee.. doh!

  • #5 / Oct 17, 2013 11:24am

    Eric N

    28 posts

    Basically from what I can tell it all comes down to jQuery conflicts. (I do have include_jquery=“no” in my exp tag)

    I included

    <a href="http://code.jquery.com/jquery-migrate-1.0.0.js">http://code.jquery.com/jquery-migrate-1.0.0.js</a>

    and it seemed to clear up most of the issues, especially the image tag item.

    I still have some issues with the Rich Text working properly (so far I’m only testing in Firefox) - The Link functionality doesn’t work and when I submit the form it’s acting a little strange as well, bringing me back to the form with the HTML code in the content view, then if I leave it and re-submit it goes in.

    Currently I use jQuery 1.9.1 - which since 1.9 apparently there were some depreciated functions that are used all over the place with Rich Text.

    I can’t be the only one who has run into this.. any ideas on how best to address it?  Thanks!

  • #6 / Oct 21, 2013 9:36am

    Eric N

    28 posts

    Seems it was jQuery - you need to run pre 1.9 to work with it. A little bit of a bummer but unless someone knows out a work around it may have to be this way, not sure yet what that means with the rest of my site’s coding since I built it all with 1.9 sitting there.
    Also had to add the fix for the Channel Form’s date picker - that was easy though (apparently will be put in the next release)

  • #7 / Oct 29, 2013 4:48am

    Bjørn Børresen

    629 posts

    A workaround could be to add a check where you include the jquery and not include if it it is on the page where your form is located (in that case you should let channel form load its jquery version). Yes, a bit hacky.

  • #8 / Oct 29, 2013 9:33am

    Eric N

    28 posts

    That’s basically what I did. ” if segment_1 == this then use jQuery version X type of thing, I don’t want to downgrade the whole site from the latest jQuery unless I have to because I will be putting in loads of custom items in the near future.
    Not exactly what I was hoping for but it will do for now. Apparently the biggest problem is with the overlay, otherwise the jQuery migrate scripts made it usable.
    The changes in 1.8 and 1.9 make some of the form automation outdated, hopefully they will update it soon.
    With it being tied to the CP there isn’t much you can do as far as changing the EE code without causing ultimate destruction to the CP.

    After all that I then found out that the richtext field wouldn’t work because people would paste from Word making an awful mess of things, something about richtext and pasting from Word just doesn’t work well at all. So its ripped down to text inputs, textarea and a file upload which the latter being the only item I need scripting for now.

  • #9 / Oct 29, 2013 9:39am

    Bjørn Børresen

    629 posts

    Yup .. re richtext, if you need richtext then the ckeditor based editors (wyvern, wygwam) can be set up to pasteAsPlainText by default (so that pasting from Word won’t mess up things).

  • #10 / Oct 29, 2013 10:02am

    Eric N

    28 posts

    Ahhh.. I’ll have to check that out thanks!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases