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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

UserDefinedForm on every page?


Go to End


16 Posts   12387 Views

Avatar
neilcreagh

Community Member, 136 Posts

11 February 2011 at 1:50am

Hey janulka did you ever get this sorted? I'm having exactly the same problem as Janulka above - anyone have any ideas?
Thanks,
Neil

Avatar
neilcreagh

Community Member, 136 Posts

11 February 2011 at 1:58am

Ok I got this working... The problem was using 'getForm' as the name of the function - it was causing a conflict somewhere. When I changed the title to something else it worked for me.

eg. my function looks like this

public function CVForm() { 
      $record = DataObject::get_one("UserDefinedForm", "URLSegment = 'submit-your-cv'"); 
      $results = new UserDefinedForm_Controller($record); 
      return $results;
} 

Avatar
CHD

Community Member, 219 Posts

14 June 2011 at 3:35am

Avatar
codepattern

Community Member, 11 Posts

14 May 2012 at 12:16am

Edited: 14/05/2012 12:19am

Hi all,

I had this working with the earlier bullds of UDF. However, with the version [v0.5.0] build, I receive the following error:

Fatal error: Call to a member function getVar() on a non-object in /html/userforms/code/model/UserDefinedForm.php on line 406

My function is similar as the link above and this post

function ShowForm1(){
$get = DataObject::get_one("UserDefinedForm");
return new UserDefinedForm_Controller($get);
}

Avatar
CHD

Community Member, 219 Posts

14 May 2012 at 9:13pm

what member data are you trying to collect?
looks like when the form is submitted the function is failing to get the member. Do you have an IF function for when there is no member?

Avatar
codepattern

Community Member, 11 Posts

15 May 2012 at 1:33pm

The original form was created with UDF. It works normally if I call the page directly. However, if I try to use the 'ShowForm()' function and the template $Form, I get the issue mentioned.

Avatar
codepattern

Community Member, 11 Posts

16 May 2012 at 10:53am

Well, looks like a bug in UDF .5,line 406 - userdefinedform.php

I have resolved it by put a 'if' clause around the following line

to

//$request = $this->getRequest();

// set the values passed by the url to the field

if ($request = $this->getRequest()) {
if($var = $request->getVar($field->name)) {
$field->value = Convert::raw2att($var);
}
}

$fields->push($field);
}

Avatar
CHD

Community Member, 219 Posts

27 April 2014 at 2:43am

If you're getting the white screen of death with this, check what JS the UserDefinedForm is including.... it may just be a JS conflict

Go to Top