Skip to content

Commit

Permalink
creando modulo de pregunte y respuesta
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloRN committed Aug 1, 2011
1 parent 64ec83f commit 0154afb
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 11 deletions.
13 changes: 6 additions & 7 deletions apps/admin/modules/respuesta/config/generator.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generator:
class: dmAdminDoctrineGenerator
param:
model_class: respuestab
model_class: respuesta
theme: dmAdmin
non_verbose_templates: true
with_show: false
Expand All @@ -13,9 +13,8 @@ generator:
list:
display:
- '=id'
- busqueda_id
- pregunta_id
- mensaje
- uri
- created_at
- updated_at
sort:
Expand All @@ -28,16 +27,16 @@ generator:
display:
- id
- mensaje
- busqueda_id
- pregunta_id
- uri
- created_at
- updated_at
form:
display:
NONE: [busqueda_id]
Pregunta: [pregunta_id]
Mensaje: [mensaje]
Others: [uri]
class: respuestabAdminForm

class: respuestaAdminForm
fields: { }
edit: ~
new: ~
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* @subpackage respuesta
* @author Your name here
*/
class respuestabAdminForm extends BaserespuestabForm
class respuestaAdminForm extends BaserespuestaForm
{
public function configure()
{
parent::configure();
unset($this['created_at'], $this['updated_at']);
}
}
15 changes: 14 additions & 1 deletion apps/front/modules/pregunta/actions/actions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@ public function executeFormWidget(dmWebRequest $request)
{
$form = new preguntaForm();

if ($request->hasParameter($form->getName()) && $form->bindAndValid($request))
if ($request->isMethod('post') && $form->bindAndValid($request))
{
$form->save();
$this->getUser()->setFlash('pregunta_form_valid', true);
$user = $this->getUser()->getDmUser();
/*$this->getService('mail')->setTemplate('solicitud_busqueda_especializada')
->addValues(array(
'titulo' => $form->getValue('titulo'),
'email' => $user->getEmail(),
'mensaje' => $form->getValue('mensaje'),
'nombre' => $user->getNombre(),
'apellidos' => $user->getApellidos()
))
->send(); */
$this->redirectBack();
}

Expand Down
5 changes: 4 additions & 1 deletion apps/front/modules/pregunta/templates/_form.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php // Vars: $form

if ($sf_user->getFlash('pregunta_form_valid'))
{
echo _tag('p.felicitaciones', 'Su solicitud ha sido enviada satisfactoriamente y ser&aacute respondida con la mayor brevedad posible ');
}
echo $form;
2 changes: 1 addition & 1 deletion lib/form/doctrine/BusquedaForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BusquedaForm extends BaseBusquedaForm
public function configure()
{
unset($this['dm_user_id'], $this['created_at'], $this['updated_at'], $this['is_active']);
$this->getObject()->setDmUserId( sfcontext::getInstance()->getUser()->getAttribute( 'dm_user_id', ' ' ,'dmSecurityUser' ));
$this->getObject()->setDmUserId( sfcontext::getInstance()->getUser()->getAttribute( 'user_id', ' ' ,'dmSecurityUser' ));
$years = range(1900, date('Y'));

$today = array(
Expand Down
12 changes: 12 additions & 0 deletions lib/form/doctrine/PreguntaForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,17 @@ class PreguntaForm extends BasePreguntaForm
{
public function configure()
{
unset($this['dm_user_id'], $this['created_at'], $this['updated_at'], $this['is_active']);
$this->getObject()->setDmUserId( sfcontext::getInstance()->getUser()->getAttribute( 'user_id', ' ' ,'dmSecurityUser' ));
$this->setValidators(array(
'titulo' => new sfValidatorString(array('min_length' =>10), array ('required' => 'Debe escribir un titulo sugerente', 'min_length' => 'El titulo debe tener al menos 10 caracteres')),
'mensaje' => new sfValidatorString(array('min_length' => 20), array('required' => 'Por favor describa su pregunta', 'min_length' => 'Por favor describa mejor su pregunta(al menos 20 caracteres) ')),

'id' => new sfValidatorDoctrineChoice(array('model' => 'busqueda', 'column' => 'id', 'required' => false))
));




}
}
2 changes: 2 additions & 0 deletions lib/form/doctrine/RespuestaForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ class RespuestaForm extends BaseRespuestaForm
{
public function configure()
{

unset($this['created_at'], $this['updated_at']);
}
}
4 changes: 4 additions & 0 deletions lib/model/doctrine/Pregunta.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
*/
class Pregunta extends BasePregunta
{
public function __toString()
{
return self::getTitulo();
}

}
1 change: 1 addition & 0 deletions web/themeSolutions/css/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,4 @@ background-color: #FFF2C4;
border: 1px solid #FBCB0D;
padding: 2px;
}
/* ----------------------------------------------pregunta form Form -------------------------------------*/

0 comments on commit 0154afb

Please sign in to comment.