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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Error When Accessing Admin


Go to End
Reply


2 Posts   945 Views

Avatar
MagicUK

Community Member, 60 Posts

11 May 2011 at 2:52am

When Accessing Admin I get the following error when in DEV mode:

[Warning] Missing argument 2 for LabelField::__construct(), called in /home/m8lighti/public_html/mysite/code/PageInt.php on line 22 and defined

10 class LabelField extends DatalessField {
11 	
12 	/**
13 	 * @param string $name
14 	 * @param string $title
15 	 * @param string $className (Deprecated: use addExtraClass())
16 	 * @param bool $allowHTML (Deprecated: use setAllowHTML())
17 	 * @param Form $form
18 	 */
19 	function __construct($name, $title, $className = null, $allowHTML = false, $form = null) {
20 		// legacy handling for old parameters: $title, $heading, ...
21 		// instead of new handling: $name, $title, $heading, ...
22 		$args = func_get_args();
23 		if(!isset($args[1])) {
24 			$title = (isset($args[0])) ? $args[0] : null;
25 			$name = $title;

The code in my PageInt.php file as per the error is:

class PageInt extends Page {
   static $db = array(
   		'contentBlurb' => 'HTMLText',
      	'Right' => 'HTMLText',
   );
   
   static $has_one = array(
   		'IntslideImageOne' => 'Image',
   		'IntslideImageTwo' => 'Image',
   		'IntslideImageThree' => 'Image',
   );
   
function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Main", new HtmlEditorField('contentBlurb', 'Interior Blurb'));
    $fields->addFieldToTab("Root.Content.Main", new HtmlEditorField('Right', 'Right Content'));
    $fields->addFieldToTab("Root.Content.Images", new LabelField("XXX")); <--- Line 22
	$fields->addFieldToTab("Root.Content.Images", new ImageField('IntslideImageOne'));
	$fields->addFieldToTab("Root.Content.Images", new ImageField('IntslideImageTwo'));
	$fields->addFieldToTab("Root.Content.Images", new ImageField('IntslideImageThree'));
	
    return $fields;
    }
 
}

Any help would be appreciated here. Thanks.

Mario

Avatar
swaiba

Forum Moderator, 1826 Posts

11 May 2011 at 3:24am

well looking at the documentation http://api.silverstripe.org/2.4/forms/fields-dataless/LabelField.html it does seem that it wants two areguments, one to name the field the other for a title. Have you tried passing a second value?