Formularios
Versión 3 (Guillermo Zdanowicz, 27/08/2011 01:02)
| 1 | 1 | Guillermo Zdanowicz | h1. Formularios |
|---|---|---|---|
| 2 | 1 | Guillermo Zdanowicz | |
| 3 | 1 | Guillermo Zdanowicz | |
| 4 | 2 | Guillermo Zdanowicz | ------------------------------------------------------------------------------------------ |
| 5 | 1 | Guillermo Zdanowicz | Ejemplo de sentencias en el form |
| 6 | 1 | Guillermo Zdanowicz | |
| 7 | 2 | Guillermo Zdanowicz | ------------------------------------------------------------------------------------------ |
| 8 | 1 | Guillermo Zdanowicz | class AreasForm extends BaseAreasForm |
| 9 | 1 | Guillermo Zdanowicz | { |
| 10 | 1 | Guillermo Zdanowicz | public function configure() |
| 11 | 1 | Guillermo Zdanowicz | { |
| 12 | 1 | Guillermo Zdanowicz | |
| 13 | 1 | Guillermo Zdanowicz | parent::setup(); |
| 14 | 1 | Guillermo Zdanowicz | |
| 15 | 1 | Guillermo Zdanowicz | unset($this['created_at'],$this['updated_at']); // quita estos campos para que no se visualicen en el formulario |
| 16 | 1 | Guillermo Zdanowicz | |
| 17 | 1 | Guillermo Zdanowicz | //formato de los campos fecha |
| 18 | 1 | Guillermo Zdanowicz | b$format = '%day%/%month%/%year%'; |
| 19 | 1 | Guillermo Zdanowicz | //define el rango de campo fecha |
| 20 | 1 | Guillermo Zdanowicz | $range = range(date('Y')-90, date('Y')-15); |
| 21 | 1 | Guillermo Zdanowicz | $years = array_combine($range,$range); |
| 22 | 1 | Guillermo Zdanowicz | // setea la condifuracion de campo fecha en el campo del formulario |
| 23 | 1 | Guillermo Zdanowicz | $this->widgetSchema['fechanac'] = new sfWidgetFormDate(array('years' => $years, 'format' => $format )); |
| 24 | 1 | Guillermo Zdanowicz | } |
| 25 | 1 | Guillermo Zdanowicz | |
| 26 | 1 | Guillermo Zdanowicz | } |
| 27 | 2 | Guillermo Zdanowicz | |
| 28 | 2 | Guillermo Zdanowicz | |
| 29 | 2 | Guillermo Zdanowicz | ------------------------------------------------------------------------------------------ |
| 30 | 3 | Guillermo Zdanowicz | //setear un valor por defecto en un campo determinado |
| 31 | 3 | Guillermo Zdanowicz | $this->widgetSchema['my_field']->setDefault(my_default_value); |
| 32 | 3 | Guillermo Zdanowicz | //ocultar un campo |
| 33 | 3 | Guillermo Zdanowicz | $this->widgetSchema['idCreador']->setOption('type', 'hidden'); |
| 34 | 3 | Guillermo Zdanowicz | // cambiar el nombre de una etiqueta |
| 35 | 3 | Guillermo Zdanowicz | $this->widgetSchema['idCreador']->setLabel('Creador'); |