也許這個問題很容易,但我沒有找到答案獲取規則屬性
在我的模型我有規則:
array('name', 'length', 'max'=>65),
在我看來,我有一些代碼:
$form->textField($model,'name');
渲染之後我有:
<input id="name" type="text" value="" maxlength="65" name="name">
一切都很好,但它有可能從視圖頁上的模型獲得最大長度屬性? 我在頁面某處顯示最大長度,但我無法獲得此屬性。
感謝
在Yii2中'getValidators()'不帶參數。 – TheStoryCoder
你可以在Yii2中使用帶'getActiveValidators()'的參數。哪個更好,因爲它只返回適用的驗證器。 – jagsler
我不得不添加驗證器類的完整路徑以使其在yii2中工作(if($ validator instanceof \ yii \ validators \ StringValidator ...) – nicolascolman