Getting rule property from Yii model -


maybe question easy, did not find answer

in model have rule:

array('name', 'length', 'max'=>65), 

in view have code:

$form->textfield($model,'name'); 

after rendering have:

<input id="name" type="text" value="" maxlength="65" name="name"> 

everything fine, possible max length property model on view page? show max length somewhere on page, can't property.

thanks

try this:

foreach ($model->getvalidators('name') $validator) {     if ($validator instanceof cstringvalidator && $validator->max !== null) {         echo 'this max length ' . $validator->max;         break;     } } 

this return validators 'name' attribute. search cstringvalidator , return max size.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -