0

I am using channel forms to publish articles and would like to use inline errors but when I have this enabled I get an error.

A PHP Error was encountered
Severity: Notice
Message: Undefined property: EE::$view
Filename: libraries/File_field.php
Line Number: 704
Fatal error: Call to a member function head_link() on a non-object in /web/nifootball2/system/expressionengine/libraries/File_field.php on line 704

My template code

 {exp:channel:form channel="reports" return="clubhouse/fixtures" class="sky-form" rules:report_body="required|min_length[50]" error_handling="inline" }
                     <header>Publish Match Report</header>
                        <input type="hidden" name="report_match" value="{segment_3}" />  
                        <input type="hidden" name="report_club" value="{club_name}">
                        <input type="hidden" name="report_club_url" value="{club_url_title}">

                      <fieldset>   
                      <section>
                            <label class="label">Title</label>
                                    {exp:teammanager:club_team_match match_id="{segment_3}" team_id="{segment_4}" }
                                    <input type="hidden" name="title" id="title" value="{match_report_type} - {home_team_name} v {away_team_name} {match_date}" size="50" maxlength="100" >
                                    <input type="hidden" name="url_title" id="url_title" value="{match_report_type}-{home_team_url}-v-{away_team_url}-{match_date}" maxlength="75" size="50">
                                    {match_report_type} - {home_team_name} v {away_team_name} {match_date}
                                    {/exp:teammanager:club_team_match}

                                </section>

                         </fieldset>

                           <fieldset>  
                           <section>
                       <label class="label">Report Body</label>
                                      {error:report_body}
                                    {field:report_body}
                            </section>
                           </fieldset>   

                           <fieldset>  
                            <section>
                            <label class="label">Cover Image</label>
                            <p>Add a cover image for the Article to be displayed beside the Article snippet on the Reports lists and at the top of the full article.</p>
                                {field:report_image}
                            </section>

                            </fieldset>  

                            <footer>
                                <button type="submit" class="btn-u">Submit</button>
                            </footer>
                        {/exp:channel:form}
                        <!-- End Publish Report Form-->
4
  • Does the error get thrown when you try to view the form or when you submit the form? Also, I notice use of the file field but is the relivent JS for the channel form to work being included (probably unrelated but worth checking)?
    – Blatant
    Aug 19, 2015 at 15:26
  • Its when I submit the form. Not sure what you mean by the JS could you elaborate thanks. Aug 19, 2015 at 15:42
  • When using the Channel Form, some fields (File Field is one!) requires some Javascript to be included. however reading (and assuming you're using the latest EE version) it seems this is taken care of. In short does the file upload field look and operate like it does in the Control Panel?
    – Blatant
    Aug 19, 2015 at 16:24
  • Any update on this topic ? I have the same issue. The weird thing is I had no issue at all at the biginning...I tried the Ajax-driven example and seeing that I cannot make it work, I cancelled my changes and ever since this I have the issue.
    – pikarge
    May 17, 2016 at 9:02

1 Answer 1

0

Seems this is reported elsewhere, and here. One solution would be as so :

Core Edits - Danger, there be pirates!!!

File : /system/expressionengine/libraries/File_field.php

Line : 699 -> 705 (EE 2.10.0 )

/**
 * Add the file browser CSS to the head
 */
private function _browser_css()
{
    ee()->cp->add_to_head(ee()->view->head_link('css/file_browser.css'));
}

Change this function as so :

/**
 * Add the file browser CSS to the head
 */
private function _browser_css()
{
    ee()->load->library('view');
    ee()->cp->add_to_head(ee()->view->head_link('css/file_browser.css'));
}

Because the error is coplaining that if there's errors it can't add the css for the file field, this is becasue ee()->view does not exist. The extra line above ensures it's loaded.

This is untested so please let me know how you fare...

3
  • That works, but gives me another error Use of undefined constant PATH_CP_THEME - assumed 'PATH_CP_THEME' Aug 19, 2015 at 16:48
  • Aha, right yes. I beleive this is because the File Field is assuming it's always being rendered in the Control Panel. This means that when the form is first loaded all is well, but when the form validates and tries to reload the form page it's thinking it's within the Control Panel! Sorry I was recycling answers, we clearly need to look a bit deeper. I'll try to take a look shortly and develop the answer.
    – Blatant
    Aug 20, 2015 at 9:39
  • I appreciate the help with this, have also posted on ee forums but nothing back yet. Aug 20, 2015 at 11:35

Your Answer

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

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