3

I'm using Channel Form/Safecracker and a File field (photo of a person) doesn't work; the UI is messed up: Clicking the "x" only goes to the top of the screen and there's no "Browse" button.

I've dumbed it down to barebones channel/fieldgroup/html, and still it's not working (unix permissions are fine). So I'm out of ideas. Does anyone have working Channel Form File field code? Here's my base that won't work. Page at http://farpoint.fcs.uga.edu/facs/site/test.

Any help is much much appreciated.

<html>
<head>
<link href="{path=css/_ee_channel_form_css}" type="text/css" rel="stylesheet" media="screen">
</head>
<body>

{exp:channel:form
    channel="people1"
    url_title="jphansen1"
    logged_out_member_id="1"
    return="site/test"
}

{field:photo1}

<input type="submit" name="submit" value="Next" />

{/exp:channel:form}

</body>
</html>
1
  • Please select an answer or give more info as to why none of the answers work for you. You can select your own answer.
    – Paul
    Commented Jan 1, 2014 at 18:07

2 Answers 2

4

It appears to be stemming from an error in the JS preventing the global EE object from being created.

Digging deeper I was able to identify the culprit:

{
  "name": "Link in this site",
  "key": "",
  "openWith": "<a href=\"http://farpoint.fcs.uga.edu/facs/template\\" > ",
  "closeWith": " < \/a>",
  "className": "btn_Linkinthissite"
}

Note the double backslash at the end of the url for openWith which breaks the quote being escaped causing a syntax error.

This is associated to a custom button in the Rich Text Editor. There is a Fixed link in this site button, so I am guessing you have noticed an issue with this before. Removing the broken button should solve the issue.

5
  • That did it! Thanks so much. Now it's kinda working, except I can't replace the file if there's already a file there. I can "X" out the file, submit, then select a file and it works, though. Any ideas?
    – jphansen
    Commented Oct 18, 2013 at 13:46
  • 1
    Internally, ExpressionEngine uses jQuery version 1.7.2. Based on this, it assumes the code it outputs is compatible with this version. You are loading jQuery version 1.9.1, which would usually cause any issues. Except, in this instance, ExpressionEngine is using jQuery.browser which was removed in jQuery 1.9.0 (api.jquery.com/jQuery.browser). I can't be certain this is what is causing the issue, but my first point of call would be to drop back to jQuery version 1.8.3 if possible (you can get a copy at the bottom of jquery.com/download). Commented Oct 18, 2013 at 23:39
  • Amazing debugging, thanks, that seems to have fixed a visual glitch where I couldn't use the "x" above a photo. Now I see how the File field is supposed to be used: to replace an existing file, you first x it out, then you can browse for a file to replace it, then submit. But upon doing this, the "replace" just deletes the file. I have to come back to the page with now no photo defined, then upload the new one. Do you know why the replace functionality isn't working? (You can replace the photo to see.)
    – jphansen
    Commented Oct 21, 2013 at 18:05
  • 1
    Just going off what information I can gather from the front end, I would say the submission is failing due to required fields (title, url_title) not being filled. By disabling inline_errors or using {field_errors}{error}{/field_errors} and {global_errors}{error}{/global_errors} in your templates, you should be able to get an idea about what is stopping the submission. Commented Oct 21, 2013 at 21:30
  • Good guess, but I made a simple channel + fieldgroup (just contains a File field) for this, and the channel just has one entry with a defined url_title, title, and File field. (On another form, the real one, the other text fields update successfully, so it looks like it's submitting ok.) I tried displaying errors and am getting none. Any other ideas or recommendations on what I can try? Thanks again.
    – jphansen
    Commented Oct 22, 2013 at 14:56
3

Turns out this was a bug. The bugreport (https://support.ellislab.com/bugs/detail/19837) says to do this, which has resolved it:

In the file system/expressionengine/fieldtypes/file/ft.file.php at line 147 replace:

container.find("input[type=hidden]").val(function(i, current_value) { with

container.find("input[type=hidden][name*='hidden']").val(function(i, current_value) {

In file system/expressionengine/libraries/File_field.php at line 125 add:

$vars['directory'] = form_hidden($field_name.'_directory', $vars['upload_location_id']);

In file system/expressionengine/views/_shared/file/field.php at line 23 add:

PHPOPEN else: PHPCLOSE

PHPOPEN=$directoryPHPCLOSE

1
  • Awesome, glad you got it sorted! Commented Oct 30, 2013 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.