Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » UserDefinedForm on every page?

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

Page: 1 2
Go to End
Author Topic: 4715 Views
  • neilcreagh
    Avatar
    Community Member
    94 Posts

    Re: UserDefinedForm on every page? Link to this post

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

  • neilcreagh
    Avatar
    Community Member
    94 Posts

    Re: UserDefinedForm on every page? Link to this post

    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;
    }

  • CHD
    Avatar
    Community Member
    218 Posts
  • codepattern
    Avatar
    Community Member
    8 Posts

    Re: UserDefinedForm on every page? Link to this post

    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);
       }

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: UserDefinedForm on every page? Link to this post

    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?

  • codepattern
    Avatar
    Community Member
    8 Posts

    Re: UserDefinedForm on every page? Link to this post

    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.

  • codepattern
    Avatar
    Community Member
    8 Posts

    Re: UserDefinedForm on every page? Link to this post

    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);
    }

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: UserDefinedForm on every page? Link to this post

    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

    4715 Views
Page: 1 2
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.