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.

Archive /

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

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

Trouble making a form with a CheckboxSetField


Go to End


4 Posts   2470 Views

Avatar
Mednezz

Community Member, 23 Posts

26 August 2007 at 10:30pm

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

Forum Moderator, 922 Posts

27 August 2007 at 10:47am

Edited: 27/08/2007 10:53am

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

Community Member, 23 Posts

27 August 2007 at 6:23pm

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

Forum Moderator, 922 Posts

27 August 2007 at 8:47pm

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