How can I define radio buttons for a model field.
class Model_Campaign extends Model_Table {
public $entity_code = 'campaign';
function init() {
parent::init();
$this->addField('nombres')->mandatory(TRUE);
$this->addField('email')->mandatory(TRUE);
$this->addField('celular')->mandatory(TRUE);
$this->addField('ciudad');
$this->addField('operador')->mandatory(TRUE);
}
}
I want to ‘operador’ field shows like radiobuttons, and I want to ‘celular’ field only accepts numeric values.
1# about radiobuttons
So, if you want to have radio buttons, this implies that either you have static list of values or you are referencing other model, thus do following:
a:
$this->hasOne("Operador", "operador"), given you have Model_Operadorb:
$this->addField("operador")->datatype("list")->listData(array());this will make drop down to appear. If you want to have radio buttons:
add
->display("radio");2# validation – read documentation: http://agiletoolkit.org/doc/form/validation
e.g.
n.b. make sure you use atk4.2 (master branch in github)
more filters: http://php.net/manual/en/filter.filters.validate.php