Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Trouble making a form with a CheckboxSetField

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: 1799 Views
  • Mednezz
    Avatar
    Community Member
    23 Posts

    Trouble making a form with a CheckboxSetField Link to this post

    Hey there,

    I'm trying to create a extended search form to search in one of my modules. But as soon as i create a CheckboxSetField i get the error : Fatal error: Call to a member function hasMethod() on a non-object in /var/www/empex4/sapphire/forms/CheckboxSetField.php on line 21

    I really can't figure out why this happends. I've shrinked the form to virtually nothing and still i get the same error. Here's my code :

    class VacatureUitgebreidZoeken extends Page {
    static $db = array(
    );
    static $has_one = array(
    );
    }

    class VacatureUitgebreidZoeken_Controller extends Page_Controller {

       function VacatureSearchForm() {
          
          // Create fields
          $test = new CheckboxSetField('Werkstatus','Werkstatus',array('Fulltime' => 'Fulltime',
                                                   'Parttime' => 'Parttime',
                                                   'Oproepbasis' => 'Oproepbasis'));
          $fields = new FieldSet(
             $test
             
          );   
          
          $submitAction = new FormAction('uitgebreidZoekenResults', 'Resultaten weergeven');
          $actions = new FieldSet(
             $submitAction
          );
          
          $form = new Form($this, 'VacatureSearchForm', $fields, $actions
             );
          return $form;
       }
       
    }

    anyone knows what to do?

    Thanks!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Trouble making a form with a CheckboxSetField Link to this post

    The problem technically is hasMethod shouldn't be called if the record doesn't exist. And it appears to have been fixed here:

    http://open.silverstripe.com/changeset?new=39192%40modules%2Fsapphire%2Ftrunk%2Fforms%2FCheckboxSetField.php&old=39003%40modules%2Fsapphire%2Ftrunk%2Fforms%2FCheckboxSetField.php

    You can add the extra check for $record to your CheckboxSetField.php file to resolve it.

    Cheers!

    Sean

  • Mednezz
    Avatar
    Community Member
    23 Posts

    Re: Trouble making a form with a CheckboxSetField Link to this post

    Great! That worked!

    I was checking rechecking and doing more checking, did it seem to be a framework failure!

    Tnx for the solution!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Trouble making a form with a CheckboxSetField Link to this post

    No problems,

    It looks like someone already ran into the same problem you had and resolved it. This fix will appear in the next release of the SS framework.

    Thanks for pointing it out!

    Cheers,
    Sean

    1799 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.