I have a dataobject FAQItem and I want the Active data to display as Y (1) or N (0) in the CMS DOM list.
Below is my code for the object with the function 'getActiveState' creating the custom values. However, when I call this in the field list array on the page all the rows show as "Y" dispite the fact that some are set to false (0).
Bit of newbit to PHP and SS. Any help much appreciated.
Thanks
Paul
<?php
class FAQItem extends DataObject {
static $db = array(
'Question' => 'Text',
'Answer' => 'HTMLText',
'Active' => 'Boolean'
);
static $has_one = array(
'FAQs' => 'FAQ'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new Checkboxfield('Active'));
$fields->push( new TextField( 'Question' ));
$fields->push( new SimpleWysiwygField( 'Answer' ) );
return $fields;
}
public function getActiveState() {
if ($this->Active=1)
{
$activestate="Y";
}
else
{
$activestate="N";
}
return $activestate;
}
}