how to display time from db table into drop downlist yii2?
this is my form field for dropdown list Time
<?= $form->field($model, 'Time')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time'),
'language' => 'en',
'options' => ['placeholder' => 'Select available time ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
Day_cust
and cust_id
is taken from the previous text input in the same form which is field by the user.
I have tried the above code but it failed to display the time available.
this is my model for schedule
public function attributeLabels()
{
return [
'schedule_id' => 'Schedule ID',
'username' => 'Username',
'day' => 'Day',
'time' => 'Time',
'availability' => 'Availability',
];
}
what I want is I want to display on the drop-down list for time
the time input in the database with the availability available
based on cust_id
and day
insert by the user in the field.
how should I do it?
if anyone wonder why i dont use dependent dropdownlist is because the cust_id is using text input same goes with the day. i didnt use the ddl for both of them.
php phpmyadmin yii2 yii2-advanced-app
add a comment |
this is my form field for dropdown list Time
<?= $form->field($model, 'Time')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time'),
'language' => 'en',
'options' => ['placeholder' => 'Select available time ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
Day_cust
and cust_id
is taken from the previous text input in the same form which is field by the user.
I have tried the above code but it failed to display the time available.
this is my model for schedule
public function attributeLabels()
{
return [
'schedule_id' => 'Schedule ID',
'username' => 'Username',
'day' => 'Day',
'time' => 'Time',
'availability' => 'Availability',
];
}
what I want is I want to display on the drop-down list for time
the time input in the database with the availability available
based on cust_id
and day
insert by the user in the field.
how should I do it?
if anyone wonder why i dont use dependent dropdownlist is because the cust_id is using text input same goes with the day. i didnt use the ddl for both of them.
php phpmyadmin yii2 yii2-advanced-app
thats quiet a clean model with a single function only, and depdrop does not have a limitation to be dependent on dropdowns only it just needs an input selector and it will trigger the depdrop as soon as the text input changes
– Muhammad Omer Aslam
Nov 19 '18 at 18:35
add a comment |
this is my form field for dropdown list Time
<?= $form->field($model, 'Time')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time'),
'language' => 'en',
'options' => ['placeholder' => 'Select available time ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
Day_cust
and cust_id
is taken from the previous text input in the same form which is field by the user.
I have tried the above code but it failed to display the time available.
this is my model for schedule
public function attributeLabels()
{
return [
'schedule_id' => 'Schedule ID',
'username' => 'Username',
'day' => 'Day',
'time' => 'Time',
'availability' => 'Availability',
];
}
what I want is I want to display on the drop-down list for time
the time input in the database with the availability available
based on cust_id
and day
insert by the user in the field.
how should I do it?
if anyone wonder why i dont use dependent dropdownlist is because the cust_id is using text input same goes with the day. i didnt use the ddl for both of them.
php phpmyadmin yii2 yii2-advanced-app
this is my form field for dropdown list Time
<?= $form->field($model, 'Time')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time'),
'language' => 'en',
'options' => ['placeholder' => 'Select available time ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
Day_cust
and cust_id
is taken from the previous text input in the same form which is field by the user.
I have tried the above code but it failed to display the time available.
this is my model for schedule
public function attributeLabels()
{
return [
'schedule_id' => 'Schedule ID',
'username' => 'Username',
'day' => 'Day',
'time' => 'Time',
'availability' => 'Availability',
];
}
what I want is I want to display on the drop-down list for time
the time input in the database with the availability available
based on cust_id
and day
insert by the user in the field.
how should I do it?
if anyone wonder why i dont use dependent dropdownlist is because the cust_id is using text input same goes with the day. i didnt use the ddl for both of them.
php phpmyadmin yii2 yii2-advanced-app
php phpmyadmin yii2 yii2-advanced-app
edited Nov 19 '18 at 14:26
rayna qarla
asked Nov 19 '18 at 11:55
rayna qarlarayna qarla
65
65
thats quiet a clean model with a single function only, and depdrop does not have a limitation to be dependent on dropdowns only it just needs an input selector and it will trigger the depdrop as soon as the text input changes
– Muhammad Omer Aslam
Nov 19 '18 at 18:35
add a comment |
thats quiet a clean model with a single function only, and depdrop does not have a limitation to be dependent on dropdowns only it just needs an input selector and it will trigger the depdrop as soon as the text input changes
– Muhammad Omer Aslam
Nov 19 '18 at 18:35
thats quiet a clean model with a single function only, and depdrop does not have a limitation to be dependent on dropdowns only it just needs an input selector and it will trigger the depdrop as soon as the text input changes
– Muhammad Omer Aslam
Nov 19 '18 at 18:35
thats quiet a clean model with a single function only, and depdrop does not have a limitation to be dependent on dropdowns only it just needs an input selector and it will trigger the depdrop as soon as the text input changes
– Muhammad Omer Aslam
Nov 19 '18 at 18:35
add a comment |
1 Answer
1
active
oldest
votes
In your ArrayHelper::map()
, make sure you have used correct database field values.
Your database field contains time
not Time
, So ArrayHelper
should be like,
ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time')
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374122%2fhow-to-display-time-from-db-table-into-drop-downlist-yii2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your ArrayHelper::map()
, make sure you have used correct database field values.
Your database field contains time
not Time
, So ArrayHelper
should be like,
ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time')
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
add a comment |
In your ArrayHelper::map()
, make sure you have used correct database field values.
Your database field contains time
not Time
, So ArrayHelper
should be like,
ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time')
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
add a comment |
In your ArrayHelper::map()
, make sure you have used correct database field values.
Your database field contains time
not Time
, So ArrayHelper
should be like,
ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time')
In your ArrayHelper::map()
, make sure you have used correct database field values.
Your database field contains time
not Time
, So ArrayHelper
should be like,
ArrayHelper::map(Schedule::find()->where(['username' => 'cust_id', 'day'=>'Day_cust','availability'=>'available'])->all(),'time','time')
answered Nov 19 '18 at 12:27
akshaypjoshiakshaypjoshi
5421216
5421216
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
add a comment |
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
yaa but still it didnt prompt what i need. i need to display all the time which have the availability is "available" based on the username and day selected
– rayna qarla
Nov 19 '18 at 13:21
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
If you are trying to implement dependent dropdown list then you should make use of ajax request. By selecting User from the previous Dropdown list, you need to make a request to the server and fetch data for that User accordingly.
– akshaypjoshi
Nov 19 '18 at 13:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374122%2fhow-to-display-time-from-db-table-into-drop-downlist-yii2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
thats quiet a clean model with a single function only, and depdrop does not have a limitation to be dependent on dropdowns only it just needs an input selector and it will trigger the depdrop as soon as the text input changes
– Muhammad Omer Aslam
Nov 19 '18 at 18:35