Ho un controller che disegna una form, dove l’utente inserisce mittente, destinatario e testo di quello che diventerà un sms.
Ho inserito i seguenti validatori:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('delivery_id, sender, recipient, status_id, quality, message', 'required'),
array('delivery_id', 'length', 'max'=>19),
array('status_id', 'length', 'max'=>11),
array('sender, recipient', 'length', 'max'=>255),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, delivery_id, sender, recipient, message, status_id', 'safe', 'on'=>'search'),
// blacklisting
array('sender', 'blacklist', 'type'=>'FROM', 'on' => 'send_from_web'),
array('recipient', 'blacklist', 'type'=>'RCPT', 'on' => 'send_from_web'),
array('message', 'blacklist', 'type'=>'TEXT', 'on' => 'send_from_web'),
);
}
ma vorrei che prestaste attenzione agli ultimi tre
array('sender', 'blacklist', 'type'=>'FROM', 'on' => 'send_from_web'),
array('recipient', 'blacklist', 'type'=>'RCPT', 'on' => 'send_from_web'),
array('message', 'blacklist', 'type'=>'TEXT', 'on' => 'send_from_web'),
Il contesto viene inizializzato dal controller, ovviamente.
Segue la routine di validazione che in realtà si limita a loggare
public function blacklist($attribute, $params)
{
Yii::log("Queue->blacklist ($attribute, " . print_r($params, true) . ")", CLogger::LEVEL_ERROR "application");
Yii::getLogger()->flush();
}
PROBLEMA: il sender viene validato, il recipient anche, il message no …
Me ne accorgo perchè viene loggato la riga per sender, per recipient, ma non quella per message…e mi sfugge il perchè
Verifiche già fatte:
-
cambio il type agli altri validatori, vengono comunque eseguiti
-
togliendo l’on dal validatore del message NON viene comunque eseguito
-
inserendo un altro validatore con stesso campo e diverso type NON viene comunque eseguito
-
scambiando l’ordine dei validatori, message non viene comunque valutato
-
visto che message era una textarea, ho provato a cambiarla in textbox, ma NON viene comunque validato
-
provato ad inserire message come safe (senza scenario), e non cambia nulla