Skip to main content

Posts

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' , ]
Recent posts

Java , convert a String to an int

   To convert a string to an in int in java we use  Integer.parseInt()  function. Example: String anyNumber = "15" ; int result = Integer . parseInt ( anyNumber ) ;   System . out . println ( result ) ;   int aaa = Integer . parseInt ( "123456" ); See the  Java Documentation  for more information. (If you have it in a  StringBuilder  (or the ancient  StringBuffer ), you'll need to do  Integer.parseInt(myBuilderOrBuffer.toString());  instead). A   very important point to consider is that the Integer parser throws NumberFormatException as stated in  Javadoc . int aaa ; String StringThatCouldBeANumberOrNot = "2623263hiworld" ; //will throw exception String StringThatCouldBeANumberOrNot2 = "2336263" ; //will not throw exception try { aaa = Integer . parseInt ( StringThatCouldBeANumberOrNot ); } catch ( NumberFormatException e ) { //Will Throw exception! //do something! anything to h

How to undo last commtis on GIT

If you have comitted wrong files to git and you want to undo it, here is what you can do : $ git commit - m "Some comment here" ( 1 ) $ git reset HEAD ~ ( 2 ) << edit files as necessary >> ( 3 ) $ git add ... ( 4 ) $ git commit - c ORIG_HEAD ( 5 ) This is what you are looking to undo This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they'll appear as "Changes not staged for commit" in  git status  and you'll need to add them again before committing). If you  only  want to  add  more changes to the previous commit, or change the commit message 1 , you could use  git reset --soft HEAD~  instead, which is like  git reset HEAD~  but leaves your existing changes stage