Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Patch: Fix error notices on "contact form" type pages.

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 2398 Views
  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Patch: Fix error notices on "contact form" type pages. Link to this post

    Hello again.

    I've run into a bunch of error notices when creating a "contact form" type page.

    First off, I get endless errors like:
    Notice: Undefined variable: field in /var/www/silverstripe/sapphire/core/model/DataObject.php on line 955
    which I fixed with this patch (explained in a previous post):
    http://www.elijahlofgren.com/silverstripe/patches/Fix-db-build-errors-silverstripe.2.0.DailyBuild.2007-05-23.patch

    Note: This patch assumes the one above has already be applied.

    Here is a patch that fixes the rest of the errors explained below:
    http://www.elijahlofgren.com/silverstripe/patches/Fix-contact-form-errors-silverstripe.2.0.DailyBuild.2007-05-23.patch

    Patch explanation:

    1. I get the following 2 errors, each repeated 4 times from inside the has_many() function:

    Notice: Undefined index: Fields in /var/www/silverstripe/sapphire/core/model/DataObject.php(796) : eval()'d code on line 1

    Notice: Undefined index: Submissions in /var/www/silverstripe/sapphire/core/model/DataObject.php(796) : eval()'d code on line 1

    I fixed this by only returning {$class}::\$has_many[\$component] if it is set.

    2. These two errors were fixed by the addition of an isset():
    Notice: Undefined index: UserDefinedForm in /var/www/silverstripe/sapphire/core/model/DataObject.php on line 638

    Notice: Undefined index: Page in /var/www/silverstripe/sapphire/core/model/DataObject.php on line 638

    3. These last two errors were fixed by adding an "else" statement to assign a variable an empty value if needed:

    Notice: Undefined variable: readOnlyAttr in /var/www/silverstripe/sapphire/forms/EditableFormField.php on line 70

    Notice: Undefined variable: disabled in /var/www/silverstripe/sapphire/forms/EditableTextField.php on line 81

    4. When clicking save draft I got the following error:

    Error in Ajax evaluator on line 974: invalid flag after regular expression
    Notice: Use of undefined constant ID - assumed 'ID' in /var/www/silverstripe/sapphire/core/model/DataObject.php on line 361
    $('sitetree').setNodeTitle("4", "Contact Us"); $('Form_EditForm').loadActionsFromString(' '); $('Form_EditForm').updateStatus('Saved (update)'); statusMessage('Saved.', 'good');

    I fixed that error by adding the needed single quotes around this line: return $this->record['ID'];

    Hope this helps,

    Elijah Lofgren

  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Re: Patch: Fix error notices on "contact form" type pages. Link to this post

    This patch fixes more errors also (to be applied in addition to the 2 listed above):
    http://www.elijahlofgren.com/silverstripe/patches/Fix-undefined-sapphire-forms-variables-silverstripe.2.0.DailyBuild.2007-05-23.patch

    Explanation:

    I made some additional fixes to sapphire/forms that fix the following errors that I encountered, in addition to more undefined variable 'disabled' errors:

    Notice: Undefined index: 1 in /var/www/silverstripe/sapphire/forms/EditableDropdown.php on line 45

    Notice: Undefined variable: optionNumber in /var/www/silverstripe/sapphire/forms/EditableDropdown.php on line 60

    Notice: Undefined index: Default in /var/www/silverstripe/sapphire/forms/EditableDropdown.php on line 62

    Notice: Undefined index: Default in /var/www/silverstripe/sapphire/forms/EditableFormField.php on line 86

    Hope this helps,

    Elijah

  • Andy
    Avatar
    230 Posts

    Re: Patch: Fix error notices on "contact form" type pages. Link to this post

    Good work! I've changed the syntax to use ? : condensed ifs instead eg:

    $disabled = ($this->readonly) ? " disabled=\"disabled\"" : '';

    2398 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.