Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

Patch: Fix error notices on "contact form" type pages.


Go to End


3 Posts   2937 Views

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

24 May 2007 at 11:44am

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

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

24 May 2007 at 3:00pm

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

Avatar
Andante

Community Member, 231 Posts

28 May 2007 at 2:40pm

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

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