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.

Customising the CMS

Checkbox in CMS


Reply

4 Posts   379 Views

Avatar
Robke

16 July 2013 at 12:54am (Last edited: 16 July 2013 12:55am), Community Member, 4 Posts

hello,

this is my first post in SS forums. I'm quite new programmer and for SS as well.
I'm building my first web and i have some troubles with checkbox field. Everything looks good, but the problem is in CMS. If i check the value "DominaKeitimas" and do "save and publish" everything works except checkbox field in CMS. Somehow CMS do not save checked value in CMS, but in database and web it works perfectly. Search gives me everything i need and dataobject as well. So my question is: what did i do wrong and how to solute this issue?

some code...
<?php
class NTObjektas extends Page{
static $db = array( 'DominaKeitimas' => 'Boolean');
public static $has_one = array("Objects" =>"Object");
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Info', new CheckboxField('DominaKeitimas', 'Domina keitimas', 1));
/* some code */
return $fields;
}
}
class NTObjektas_Controller extends Page_Controller{
}

p.s. sorry for my broken english.

Avatar
zenmonkey

16 July 2013 at 3:28am Community Member, 528 Posts

You're setting the value on the field which is overriding the set value on the CMS

change
$fields->addFieldToTab('Root.Info', new CheckboxField('DominaKeitimas', 'Domina keitimas', 1));
to
$fields->addFieldToTab('Root.Info', new CheckboxField('DominaKeitimas', 'Domina keitimas'));

Avatar
Robke

16 July 2013 at 4:13am (Last edited: 16 July 2013 4:14am), Community Member, 4 Posts

sorry, but its not working....
and i don't know why... there are some problems with DropdownField...

$veiksmoTipas = new DropdownField('VeiksmoTipas', 'some text', array(
'Siulome' => 'Siūlome',
'Ieskome' => 'Ieškome',
'Vystomi' => 'Vystomi Objektai'
));
this one works perfectly, but another is the same problem as with the checkbox field....

$sandorioTipas = new DropdownField('SandorioTipas', 'some text', array(
'Nuoma' => 'Nuoma',
'Pardavimas' => 'Pardavimas'
));
$sandorioTipas->setEmptyString('Pasirinkite');

$fields->addFieldToTab('Root.Info', $sandorioTipas);

values in the web and database are shown, but in CMS didn't saved.... strange

Avatar
Robke

19 July 2013 at 8:30pm Community Member, 4 Posts

SOLVED:

i don't know what was wrong, but i changet my Variables names and all the things keep working :)