Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Checkbox in CMS

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

Page: 1
Go to End
Author Topic: 360 Views
  • Robke
    Avatar
    Community Member
    4 Posts

    Checkbox in CMS Link to this post

    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.

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: Checkbox in CMS Link to this post

    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'));

  • Robke
    Avatar
    Community Member
    4 Posts

    Re: Checkbox in CMS Link to this post

    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

  • Robke
    Avatar
    Community Member
    4 Posts

    Re: Checkbox in CMS Link to this post

    SOLVED:

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

    360 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.