Skip to main content

Posts

Showing posts with the label form

Yii2 . FORM How to make dependant drop down. Where second drop downs values are dependant on first drop down selection

In form file : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <? = $form -> field ( $model , 'country_id' ) -> dropDownList ([ "5" => 'USA' , "6" => "Pakistan" ], [ 'prompt' => 'Select Country' , 'onchange' => ' $.get( "' . \yii\helpers\Url :: toRoute ( '/site/getstates' ) . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html :: getInputId ( $model , 'state_id' ) . '" ).html( data ); } ); ' , 'class' => 'form-control' ] ); ?> <? = $form -> field ( $model , 'state_id' ) -> dropDownList ( [ 'prompt' => 'Select State' , ] ...

YII Client side form validation error doesn't prevent form submit

YII Client side form validation error doesn't prevent form submit To get this behavior you just need to add 'clientOptions' => array('validateOnSubmit'=>true), to your configuration so it would look like this: $form=$this->beginWidget( 'CActiveForm', array( 'id'=>'member-form', 'enableAjaxValidation'=>false, 'enableClientValidation'=>true, 'clientOptions' => array('validateOnSubmit'=>true), ) );

Yii, Ccaptcha. Captcha image doesnt show

Yii Ccaptcha Captcha refers to the imagery device ment to capture bots attempting to fill out your forms for automatic spam submission. It auto generates images with codes that users have to input to submit a form to avoid such spam bot issues. The only real forms that would require this device would be forms accessible to none users of your site, all other forms should be filtered by needing access to your site from a membership. Common Captcha Problems Version 1.1.x Captcha Image doesn't load on page? The first step is to see if the gd extension library is installed and functional for your php engine to read and display the image file. To do this, make a php file with the following code: phpinfo(); This will tell you all the specs of your php install. gd extension is there and working, now what? If the gd extension is operational then the error lies within your code. Let's go through this step by step: Did you define a public variable & rule set ...

yii, some form validation examples

Yii some basic form validations using rules in models like email, compare password (match password), date, unique, captcha etc Below is full model code: <?php /** * This is the model class for table "users". * * The followings are the available columns in table 'users': * @property integer $user_id * @property string $user_name * @property string $user_password * @property string $user_email * @property string $user_gender * @property integer $user_age * @property string $user_location * @property string $user_avatar * @property string $user_facebook_id * @property integer $user_receive_newsletters_flag * @property integer $is_admin */ class Users extends CActiveRecord { public $confirm_password , $user_captcha ; /** * Returns the static model of the specified AR class. * @return Users the static model class */ public static function model ( $className = __CLASS__) { return parent :: model (...