Комментарии:
you just copy the code ,its hard to type atleast yu could have given the link where your code is and we can re edit in according to our work......some of us are slow learners
Ответитьthankyou so much sir
ОтветитьHow to make three levels?
Ответитьty dude!)
ОтветитьVery Good.! Tanks. ;)
Ответить500 internal server error guys please help
Ответить$countBranches = Facultypaper::find()
->select(['facultypaper.*'])
->leftJoin('courses', 'facultypaper.faculty_paper_course_id = courses.course_id' )
->where(['paper_faculty_id' => $facultyid])
->andwhere(['faculty_paper_semester_id' => $id])
->count();
$branches = Facultypaper::find()
->select(['courses.course_id' ,'courses.courses_name'])
->leftJoin('courses', 'facultypaper.faculty_paper_course_id = courses.course_id' )
->where(['paper_faculty_id' => $facultyid])
->andwhere(['faculty_paper_semester_id' => $id])
->all();
if ($countBranches > 0)
{
echo "<option>Select Course</option>";
foreach ($branches as $branch)
{
echo "<option value='".$branch->faculty_paper_course_id."'>".$branch->courses.courses_name."</option>";
}
}
else
{
echo "<option>-</option>";
}
this i my code for relational dropdown but i am not able to get second table columns its show only first table column please help me how to join bot table. Here courses_name show error
It was perfect .. thank you very much
ОтветитьGood job ... you have explained it very well.
I have a question , is there any way to add "Expiry date" in RBAC.
Can you also create one video on kartik tree view control.
how to make an dependent drop down list search in grid view?
ОтветитьHi Guys, I wanna add some code lines because I loss a lot of time with this tutorial. Alwais the fields populated all data.
The code: (Remenber i didn´t use the same name in tables of the DB)(Change for that u r using)
'onchange'=>'$.post("index.php?r=branches/lists&id='.'"+$(this).val(),function( data ){
$( "select#departments-branch_id" ).html( data );
});
'
hello
i want to ask, how about to make dependent auto suggest dropdown search?
i'm newbie in this framework :)
ขอบคุณครับ Thank you.
ОтветитьGood Tutorial to learn.One question that i want to ask, first time when the page loads it shows all value in second dropdown list ,but when option is choose from first it changes as coded.
So how to hide all lists in second dropdown when nothing is selected in first?
Hello i got problem
when i save the data in database
the input of drop down identified by id
how to change the id into Name of value?
thanks for the tutorial, but i have a similiar case like this, dependent dropdown to checkboxlist. if i choose one value from the dropdown the checkbox will generated by the key value.
but when i want to save, i cant get the value of the dependent checkbox.
this my code part from view and controller.
- view
<?= $form->field($model, 'cp_countrytarget')->dropDownList(
ArrayHelper::map(\app\models\Countries::find()->all(), 'countries_id', 'name'),
[
'prompt' => 'Select Country',
'class' => 'dependent-input form-control',
'onchange' => '$.get("index.php?r=tbcampaign/countries&id='.'"+$(this).val(), function(data) {
$("#tbcampaign-cp_statetarget").html(data);
});'
]); ?>
<?=$form->field($model, 'cp_statetarget')->checkboxlist([]);?>
- controller
public function actionCountries($id)
{
$states = States::find()>where(['country_id' => $id])>all();
foreach ($states as $state)
{
return Html::checkboxList('Tbcampaign[cp_citiestarget][]',[],ArrayHelper::map($states, 'name', 'name'), []);
}
hope i can get any solution, thanks before :)
so at the moment , when company is not chosen , branches filled by some trash?
ОтветитьHow can we update dropdown on page load?
Ответитьhello, if i use PrettyUrl how i should send requests?
Ответитьwhich editor you are using?
ОтветитьThank you so much, you helped me a lot with this lecture,
never imagined the solution of echoing the <option> value and how the javascript post handle the html code to populate the dropdown list, how did you come up with such a brilliant idea?
I'm using the concept of your post to selected list of value, I'm using for a barcode scanner input, since it uses text input, I don't use the onchange from the yii2 but I'm using the javascript if the id of the text input form changes then pass the barcode value and then the post pass the value generated from the controllers that you've shown above, only since I can't overcome the distinct issue, I used findBySql rather than find, much more familiar and easy to understand if the person is common with using sql queries
How do I do one for three dependent drop downs ?
ОтветитьRather going to the DB twice we can just check if the branches exist.,
/**
$count = Branches::find()
->where(['companies_company_id' => $id])
->count();
*/
$branches = Branches::find()
->where(['companies_company_id' => $id])
->all();
if ($branches)
{
foreach ($branches as $branch) {
echo '<option value="' . $branch->branch_id . '">' . $branch->branch_name . '</option>';
}
} else {
echo "<option> - </option>";
}
Respect
ОтветитьWoow... it's awesome...
thaaank ;)!!!
I want to update a GridView when I select a DropDownList, how can I do that? Thanks :)
Ответитьhi. Your lessons is very good. I have some questions. I have 403(Forbidden) error. This fixed by adding some rules in contoller behaviors method, but i cant understand how. Can you share your BranchesController, pls? Or explain, how fix this problem?
ОтветитьI want to update a text input value according to the selected item in the dropdownlist, how can I do that? Thanks :S
ОтветитьVery useful
ОтветитьVery good tutorial. Is it possible to use the same methodology to make a dependant sortable input? Ie. when selecting from a drop down list, the sortable input changes content. I think this would require 2 $post - one for updating the list items and one for updating the id list. Anyone tried this?
Ответить$countBranches and $brances? 2 query? realy?
$branches = Branchs::find()
->where(['companies_company_id' =>$id])
->all();
if (!empty($branches)) {
//do something... make options list
} else {
//make empty list
}
hi, code id not working in my app. could you please share the your code ? thanks
Ответитьyou are using the jQuery function $.post, so why are you passing "id" as a paramater for action when there is possibility of use slightly different expression as follows - $.post(someUrl,{"id" : $(this).val()}, function(data){ //code to replace html}), and in controller yii::$app->request->post('id'), for example?
ОтветитьDid you/someone have the same solution using kartik-v select2 and depdrop widgets.
Thanks
Hello!
I want to know how can i create 'views' folder which can be used from backend and from frontend sides.
I create 'views' folder in the base common folder (common\views) and create file inside this folder(common\views\_selectOptions.php). But i could'n do render partial from backend.
thanks:)
Hello, in this part lesson i have some problem, i was create 2 company, every company has 2 branch. but when select company id 1 ,still show all branch id, where is my fault, please help :)
ОтветитьThanks for such a detailed tutorial, I am facing one problem in this, when updating the details, we have to again select the parent dropdown
ОтветитьHi, thanks for share, just there is a strange behaviors when generating js code, you might end up with encoded code like: "e;index.php?r=branches..."e;
to avoid this behaviors I used registerJs like the following:
'onchange' => $this->registerJs('
$(\'#departments-companies_company_id\').change(function(){
$.post("index.php?r=branches/lists&id="+$(this).val(), function(data){
$("select#departments-branches_branch_id").html(data);
});
});
')
the rest of code remain same, and nothing extra to import.
Hello,How can I achieve this "auto search drop-down" select box because I am not getting error.
Hope you help me asap. Thanks
Assalam aleykum! Your tutorials are very good. in 2 days i gained such information about YII2 which i couldnot get in a month by searching all articles. And i got queston: what chrome extention do you use to check get/post request? In the this video u started using it at 3.07.
ОтветитьI was getting forbidden return message than I just added in the branchesController behavior method the actionLists in the rule action list. But this is a very good tutorial. Congratulations...
ОтветитьCTRL + SHIFT + D in sublime duplicates the selection or the line your cursor is currently in. No more copy/paste for you:)
You're welcome!
Thank you for your great tutorials! One question though: Why you're pre-populating the branches dropdown with all available branches when you'll overwrite it later? It should be an empty drop-down or even hidden dropdown, which will only be visible if you have a company selected.
Greetings from Europe!
Thank you very much your tutorials are always really very helpful.
I'm really sorry to bother you.
Suppose you have done a dependent drop down list also for branches to show the related departments.
If you select the company name, you have all the related branches and selecting a branch, all the departments. And that's ok. If you don't press create, but you change your mind and change the company name, the branches is changing but the department remains the same. Is there a polite way to "reset" also the department when the company changes?
thank you so much
Thanks, very nice & very Simple,
Please, I would ask about RBAC Lesson, is finished Lesson as part 1 & part 2?
Thanks a lot ^_^
thank
Ответить