Form Rules Message

Hi i have a form and this is the rules :




public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('nome, utente, copertina, trailer, genere, mymovies, durata, data, data_ins, trama, q_video, q_audio, nome_link1, link1', 'required'),

			array('copertina, trailer, mymovies, link1', 'url','message'=>'Inserisci un indirizzo corretto,L\'indirizzo deve iniziare con http:// es http://freefilm.altervista.org'),

			array('q_video, q_audio', 'numerical', 'integerOnly'=>true),

			array('durata','numerical', 'integerOnly'=>true,'message'=>'Inserisci la durata del film in minuti '),

			array('nome, genere', 'length', 'max'=>50),

			array('nome', 'length', 'min'=>3,'message'=>'Lunghezza titolo troppo corta'),

			array('data', 'date', 'format'=>'yyyy/mm/dd','message'=>'Inserisci una data nel formato anno(4 cifre)mese (2 cifre) giorno (2 cifre) es: 2010/12/28'),

			array('copertina, trailer, mymovies', 'length', 'max'=>300),

			array('nome_link1, nome_link2, nome_link3, nome_link4, nome_link5', 'length', 'max'=>20),

			array('link1, link2, link3, link4, link5', 'length', 'max'=>100),

			// The following rule is used by search().

			// @todo Please remove those attributes that should not be searched.

			array('nome', 'safe', 'on'=>'search'),

		);

	}



I try to change the message of nome’s field :


array('nome', 'length', 'min'=>3,'message'=>'Lunghezza titolo troppo corta'),

But i have ever this message :


Nome is too short (minimum is 3 characters).

Can i change it?

you are setting length rule for nome twice so specify it single time and then proceed

Now this is the rules :





public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('nome, utente, copertina, trailer, genere, mymovies, durata, data, data_ins, trama, q_video, q_audio, nome_link1, link1', 'required'),

			array('copertina, trailer, mymovies, link1', 'url','message'=>'Inserisci un indirizzo corretto,L\'indirizzo deve iniziare con http:// es http://freefilm.altervista.org'),

			array('q_video, q_audio', 'numerical', 'integerOnly'=>true),

			array('durata','numerical', 'integerOnly'=>true,'message'=>'Inserisci la durata del film in minuti '),

			array('genere', 'length', 'max'=>50),

			array('nome', 'length', 'min'=>3,'max'=>50,'message'=>'Lunghezza titolo errata deve essere compresa tra 3 e 50 caratteri'),

			array('data', 'date', 'format'=>'yyyy/mm/dd','message'=>'Inserisci una data nel formato anno(4 cifre)mese (2 cifre) giorno (2 cifre) es: 2010/12/28'),

			array('copertina, trailer, mymovies', 'length', 'max'=>300),

			array('nome_link1, nome_link2, nome_link3, nome_link4, nome_link5', 'length', 'max'=>20),

			array('link1, link2, link3, link4, link5', 'length', 'max'=>100),

			// The following rule is used by search().

			// @todo Please remove those attributes that should not be searched.

			array('nome', 'safe', 'on'=>'search'),

		);

	}



The error’s message is the same

use the "tooLong" and "tooShort" attribute to customize this message:




array('nome', 'length', 'min'=>3, 'max'=>50,

  'tooLong'=>'Lunghezza titolo errata deve essere compresa tra 3 e 50 caratteri',

  'tooShort'=>'Lunghezza titolo errata deve essere compresa tra 3 e 50 caratteri'

),



the “message” is only used if you want an exact length with ‘is’ attribute:




array('nome', 'length', 'is'=>100, 'message'=>'...'),



CStringValidator

Tanks …