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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Userforms :: validation bug


Reply


21 Posts   5783 Views

Avatar
dalesaurus

Community Member, 283 Posts

22 September 2009 at 4:44am

Hmmm, from here I don't think I can provide much more insight. I think you just need to tweak the form require values, but UserForms are not my strength. I think you should try opening another question in the Modules or Forms forum where someone with more specialty can assist.

Avatar
Junglefish

Community Member, 109 Posts

22 September 2009 at 8:51pm

Will do. I've reposted the issue to the All Other Modules area.

Thanks for your help.

jf/

Avatar
Junglefish

Community Member, 109 Posts

25 September 2009 at 9:10pm

Okay, I know *what* it is, but I don't know how to fix it. It would appear that UserForms is clashing with Event_Calendar.

I have the Event_Calendar module installed and have created a GlobalCalendarWidget that makes the calendar widget appear in the sidebar on all my pages.

In mysite/code/page.php I have this:

function GlobalCalendarWidget() {
   $calendarPage = DataObject::get_one("Calendar");
   return new CalendarWidget($calendarPage);
}

and in my [theme]/templates/Includes/RightBar.ss template I have this:

$GlobalCalendarWidget

If I remove them both, the UserForms error goes away.

With the code commented out, there are three JS scripts in the source:

<script type="text/javascript" src="http://localhost/SilverStripe/jsparty/jquery/jquery.js?m=1227671444"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/jsparty/jquery/plugins/validate/jquery.validate.min.js?m=1210129496"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/mysite/javascript/menu.js?m=1239714101"></script>

But when Event_Calendar is on the page, there are 6 additional scripts:

<script type="text/javascript" src="http://localhost/SilverStripe/event_calendar/javascript/locale/date_en.js?m=1247672972"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/event_calendar/javascript/jquery-1.2.6.min.js?m=1237479890"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/event_calendar/javascript/jquery.date.js?m=1247672932"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/event_calendar/javascript/jquery.datePicker.js?m=1237479890"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/event_calendar/javascript/calendar_core.js?m=1238950836"></script>
<script type="text/javascript" src="http://localhost/SilverStripe/event_calendar/javascript/calendar_widget.js?m=1237479890"></script>

So, something in the Event_Calendar scripts is 'clashing' with something in the first three scripts, but.... hell, where do I start looking..?

jf/

Avatar
Willr

Forum Moderator, 5513 Posts

26 September 2009 at 6:33pm

So, something in the Event_Calendar scripts is 'clashing' with something in the first three scripts, but.... hell, where do I start looking..?

Have a look in the code in the event calendar module for the Requirements() it is including its own version of jquery where as userforms (and event_calendar for that matter) should be including the one in jsparty. Edit the link to use the one in jsparty and see if that fixes it (or it could be a plugin conflicting)

Avatar
Junglefish

Community Member, 109 Posts

28 September 2009 at 9:14pm

Hi Willr

Thanks for your suggestions, however, things are still not going well :-( Here's what I've tried...

a) In event_calendar/code/CalendarEvent.php I find these three lines in the init() function:

      Requirements::css('event_calendar/css/calendar.css');
      Requirements::javascript('event_calendar/javascript/jquery-1.2.6.min.js');
      Requirements::javascript('event_calendar/javascript/calendar_core.js');

If I simply comment them out, the calendar continues to work fine, but I still get the same conflict error with UserForms.

b) In event_calendar/templates/CalendarWidget.ss I find this line:

      <% require javascript(event_calendar/javascript/jquery-1.2.6.min.js) %>

If I replace it with:

      <% require javascript(jsparty/jquery/jquery.js?) %>

the calendar still continues to work fine, but I still get the same conflict error with UserForms.

If I remove it altogether, the calendar widget no longer loads and I get the following errors:

      "jQuery is not defined
       http://localhost/SilverStripe/event_calendar/javascript/jquery.datePicker.js?m=1237479890"

      "jQuery is not defined
       http://localhost/SilverStripe/event_calendar/javascript/calendar_widget.js?m=1237479890"

Coflicting plugins?? If so, where do I look next?

jf/

Avatar
dalesaurus

Community Member, 283 Posts

29 September 2009 at 5:09am

As Will noted above SS includes some versions of jQuery core/plugins that have been modified to remove use of the $ in order to avoid conflicts with Behavior/Prototype (used in UserForms).

It does not appear that the Event_Calendar module does this, thus it will always be broken when loading both modules at the same time.

You can try fixing the jQuery libs in Event_Calendar yourself by finding and replacing $ with jQuery, saving as a new file, and useing Requirements:: to include that one instead. BE ADVISED YOU RUN A VERY HIGH RISK OF BREAKING THE jQuery PLUGINS. I have done something similar before and it does work: http://open.silverstripe.com/ticket/4555

Your other options are wait for 2.4 when all JS should be refactored into jQuery exclusively or try another set of modules to do what you are trying to do (or code the forms yourself).

Avatar
Junglefish

Community Member, 109 Posts

29 September 2009 at 8:12pm

@dalesaurus

Thanks for the info, *and* the warning. When do you think 2.4 might be ready for release?

jf/

Avatar
dalesaurus

Community Member, 283 Posts

30 September 2009 at 6:35am

No date set yet, but the last estimate I heard was ~4-6mo.

http://open.silverstripe.com/roadmap

Not idea in your situation, though...