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.

Archive

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

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

Trouble making a form with a CheckboxSetField


Reply

4 Posts   1811 Views

Avatar
Mednezz

26 August 2007 at 10:30pm Community Member, 23 Posts

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!

Avatar
Sean

27 August 2007 at 10:47am (Last edited: 27 August 2007 10:53am), Forum Moderator, 921 Posts

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

Avatar
Mednezz

27 August 2007 at 6:23pm Community Member, 23 Posts

Great! That worked!

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

Tnx for the solution!

Avatar
Sean

27 August 2007 at 8:47pm Forum Moderator, 921 Posts

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