text-field-img

Replace Textfield by image to prevent data crawing bot
4 followers

Create image text field helping prevent information crawing bot.

Field images should be auto created once in first view time, and be removed when data object updated.

Requirements

php_gd

Usage

attach behavior and call to creating in actionView, and removing in actionUpdate.

/* attach behavior */
public function behaviors() {
    return array(
        'fieldImg' => array(
            'class' => 'FieldImgBehavior',
            'prefix' => 'c',
            'protectFields' => array('address', 'address2', 'tel', 'fax', 'establishment'),
            'imgDir' => Yii::app()->params['companyImgFieldsDir'],
        ),
    );
}
 
/* base image object handle will be company */
$this->setObjBaseDir( $model->company_id );
 
/* Company's branches address fields with 'branch' model name */
$branches = Branches::model()->findAllByAttributes(array('company_id' => $model->company_id));
$this->genFieldsImage($branches , 'id', 'branch');
...
/* Company's address field with 'default' model name */
$this->genFieldsImage($model, 'company_id');
 
....
/* remove */
removeAllImgFields( $model->company_id )
 
...
/* in view.php */
<!-- address of company -->
<?php echo $this->getFieldImageTag('address', $model->company_id); ?>
<!-- address of branches -->
<?php foreach ($branches as $branch): ?>
     <?php echo $this->getFieldImageTag('address', $branch->id, 'branch');?>
....

Resources

Check the address field.

Be the first person to leave a comment

Please to leave your comment.

Create extension