part of my schema:
## comunication ##
comunicacion:
actAs: { Timestampable: ~, Signable: ~ }
columns:
id: { type: integer, primary: true, autoincrement:
true }
user_id: { type: integer, notnull: true }
direccion_id: { type: integer, notnull: true }
documento: { type: string(100), notnull: true }
fecha: { type: date, notnull: true }
correlativo: { type: string(50), notnull: true, unique: true }
revision: { type: boolean, default: false }
status: { type: boolean, default: true }
texto: { type: text, notnull: true }
notas: { type: text, notnull: false }
relations:
User:
class: sfGuardUser
foreign: id
local: user_id
type: one
onDelete: restrict
foreignType: one
foreignAlias: User
Direccion:
class: direccion
foreign: id
local: direccion_id
type: one
onDelete: restrict
foreignType: one
foreignAlias: Direccion
Destinatario:
class: Comunicacion_Destino
type: many
local: id
foreign: comunicacion_id
## comunication destiny ##
comunicacion_destino:
actAs: { Timestampable: ~ }
columns:
id: { type: integer, primary: true, autoincrement:
true }
comunicacion_id: { type: integer, notnull: true }
user_profile_id: { type: integer, notnull: true }
relations:
Comunicacion:
class: Comunicacion
type: one
local: comunicacion_id
foreign: id
UserProfile:
class: sfGuardUserProfile
type: one
local: user_profile_id
foreign: id
--------------------------------------
comunicacionForm.class.php:
class comunicacionForm extends BasecomunicacionForm
{
public function configure()
{
parent::setup();
unset(
$this['id']
);
$this->setWidgets(array(
'revision' => new sfWidgetFormInputCheckbox(),
'status' => new sfWidgetFormInputCheckbox(),
'user_id' => new sfWidgetFormInput(),
'direccion_id' => new sfWidgetFormInput(),
'correlativo' => new sfWidgetFormInput(),
'fecha' => new sfWidgetFormInput(),
'documento' => new sfWidgetFormInput(),
'status' => new sfWidgetFormInputCheckbox(),
'texto' => new sfWidgetFormTextarea(array(), array('cols'
=> 90, 'rows' => 15)),
'notas' => new sfWidgetFormTextarea(array(), array('cols'
=> 90, 'rows' => 5)),
));
$this->setValidators(array(
'revision' => new sfValidatorBoolean(array('required' =>
true)),
'status' => new sfValidatorBoolean(array('required' =>
true)),
'user_id' => new sfValidatorString(array('required' =>
true)),
'direccion_id' => new sfValidatorString(array('required' =>
true)),
'correlativo' => new sfValidatorString(array('required' =>
true)),
'fecha' => new sfValidatorString(array('required' =>
true)),
'documento' => new sfValidatorString(array('required' =>
true)),
'texto' => new sfValidatorString(
array('min_length' => 100),
array('required' => 'El comunicado debe
contener al menos 100 caracteres')),
'notas' => new sfValidatorString(array('required' =>
false)),
));
$destinoForm = new comunicacion_destinoForm();
unset($destinoForm['id']);
$this->embedForm('destinatario', $destinoForm);
//Debe ir a revision?
$objeto = new Comunicacion();
$this->setDefault('revision', $objeto->aRevision($this-
>getOption('user')));
$this->widgetSchema->setNameFormat('comunicacion[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this-
>validatorSchema);
$this->validatorSchema->setOption('allow_extra_fields', true);
$this->setupInheritance();
}
}
---
class comunicacion_destinoForm extends Basecomunicacion_destinoForm
{
public function configure()
{
parent::setup();
unset(
$this['id'],
$this['comunicacion_id'],
$this['created_at'],
$this['updated_at']
);
$this->setWidgets(array(
'user_profile_id' => new sfWidgetFormDoctrineChoice(array(
'model' => 'Direccion',
'multiple' => true,
'method' => 'obtenerDestinatarios',
'key_method' => 'getNombre',
'table_method' => 'findAll'
)),
));
$this->setValidators(array(
'user_profile_id' => new sfValidatorDoctrineChoice(
array('model' => $this-
>getRelatedModelName('UserProfile')),
array('required' => 'Debe seleccionar, al
menos, un destinatario')
),
));
$this->widgetSchema->setNameFormat('comunicacion_destino[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this-
>validatorSchema);
$this->setupInheritance();
}
}
I'm guessing i have to rewrite the SaveEmbedded method.
Thanks!!!
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en