Add class t0 submit button Yii

If you have a form the submit button looks like this:

<?php echo CHtml::submitButton($model->isNewRecord ? ‘New’ : ‘Save’)); ?>

To add a specific class to it you should make this change:

<?php echo CHtml::submitButton($model->isNewRecord ? ‘New’ : ‘Save’,array(‘class’ => ‘btn btn-primary’)); ?>

 

Yii add captcha to form

for me (to find it quickly) i add the procedure to add captcha to a form for a model using Yii framework.

1. Add to _form.php

<?php if(CCaptcha::checkRequirements()): ?>
<div>
<?php echo $form->labelEx($model,’verifyCode’); ?>
<div>
<?php $this->widget(‘CCaptcha’); ?>
<?php echo $form->textField($model,’verifyCode’); ?>
</div>
<div>Please enter the letters as they are shown in the image above.
<br/>Letters are not case-sensitive.</div>
<?php echo $form->error($model,’verifyCode’); ?>
</div>
<?php endif; ?>
2. Add to models/yourModel.php

 

public $verifyCode;
3. Add to models/yourModel.php inside of attributeLabels():
‘verifyCode’=>’Verification Code’,
4. Add to models/yourModel.php inside of rules():
array(‘verifyCode’, ‘captcha’, ‘allowEmpty’=>!CCaptcha::checkRequirements()),
5. Add to controllers/yourModel.php:
public function actions()
{
return array(
‘captcha’=>array(
‘class’=>’CCaptchaAction’,
‘backColor’=>0xFFFFFF,
),
);
}
6. Add in controllers/yourModel.php to accessRules() the action captcha for normal user:
¬†array(‘allow’,
‘actions’=>array(‘index’,’view’,’captcha‘),
‘users’=>array(‘*’),
),
result:
Screen Shot 2013-09-14 at 12.47.22 PM
That’s it.
tj

The uploaded file exceeds the upload_max_filesize directive in php.ini

If you build more than one or two websites for sure you met this error message:

The uploaded file exceeds the upload_max_filesize directive in php.ini.

The solution is simple. In www folder you find a file called: “.htaccess”. In this file you must write the following lines:

########
php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 500
php_value max_input_time 500
#########