<?php

Goweb::loadClass('Goweb_Form_Model_Element');

/**
 * Goweb Sitemanager 5 Framework
 * @version    5.1.1
 * @category   Goweb
 * @package    Form_Model_Element
 * @author     I&D <dev@goweb.pt>, Pedro Pinto <ppinto@goweb.pt>
 * @copyright  2010 (c) Goweb (http://www.goweb.pt)
 */
class Goweb_Form_Model_Element_Checkbox extends Goweb_Form_Model_Element {

    /**
     * Metodo obrigatorio as classes herdeiras do Goweb_Form
     */
    public function setup() {
        // label
        $this->label = $this->Text();
        $this->label->size = 40;
        $this->label->maxlength = $this->_model->getColParam('label', 'maxlength');
        $this->label->label = $this->_model->getColParam('label', 'label');
        $this->label->error_class = 'error';
        $this->label->focus_class = 'focus';
        $this->label->help = $this->_model->getColParam('label', 'help');
        $this->label->validators->Required(translateAdmin('O campo <b>{{campo}}</b> &eacute; de preenchimento obrigat&oacute;rio.', $this->label->label));

        // ordem
        $this->ordem = $this->Text();
        $this->ordem->size = 20;
        $this->ordem->maxlength = $this->_model->getColParam('ordem', 'maxlength');
        $this->ordem->label = $this->_model->getColParam('ordem', 'label');
        $this->ordem->error_class = 'error';
        $this->ordem->focus_class = 'focus';
        $this->ordem->help = $this->_model->getColParam('ordem', 'help');
        $this->ordem->validators->Integer(translateAdmin('O campo <b>{{campo}}</b> n&atilde;o &eacute; um n&uacute;mero inteiro.', $this->ordem->label));

        // multiple
        $this->multiple = $this->Checkbox();
        $this->multiple->label = $this->_model->getColParam('multiple', 'label');
        $this->multiple->error_class = 'error';
        $this->multiple->focus_class = 'focus';
        if ($this->_model->getColParam('multiple', 'default') && $this->_model->getColParam('multiple', 'default') == '1') {
            $this->multiple->value = '1';
        }
        $this->multiple->help = $this->_model->getColParam('multiple', 'help');

        // options
        $this->options = $this->Textarea();
        $this->options->cols = '45';
        $this->options->rows = '10';
        $this->options->label = $this->_model->getColParam('options', 'label');
        $this->options->error_class = 'error';
        $this->options->focus_class = 'focus';
        $this->options->help = $this->_model->getColParam('options', 'help');
        $this->options->validators->Required(translateAdmin('O campo <b>{{campo}}</b> &eacute; de preenchimento obrigat&oacute;rio.', $this->options->label));

        // required
        $this->required = $this->Checkbox();
        $this->required->label = $this->_model->getColParam('required', 'label');
        $this->required->error_class = 'error';
        $this->required->focus_class = 'focus';
        if ($this->_model->getColParam('required', 'default') && $this->_model->getColParam('required', 'default') == '1') {
            $this->required->value = '1';
        }
        $this->required->help = $this->_model->getColParam('required', 'help');

        // submit
        $this->submit = $this->Submit();
        $this->submit->value = translateAdmin('Gravar');
        $this->submit->class = 'form_submit';
        $this->submit_and_new = $this->Submit();
        $this->submit_and_new->value = translateAdmin('Gravar e adicionar novo');
        $this->submit_and_new->class = 'form_submit_and_new';
        $this->submit_and_continue = $this->Submit();
        $this->submit_and_continue->value = translateAdmin('Gravar e continuar a editar');
        $this->submit_and_continue->class = 'form_submit_and_continue';
    }
}