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

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -