This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi support team,
Currently, I wanna insert a dropdown menu inside to check box list widget. Each checkbox will have each this dropdown.
I tried do that, but it will be shown as below:
Instructional Design for New Designers Manual <select name="type[1]"><option >elective</option><option >manditory</option><option >choice</option></select>
It's not auto generate dropdown list. It just shown: <select name="type[1]"><option >elective</option><option >manditory</option><option >choice</option></select>
Please help me solve this issue. Thanks,
I don't think this will ever be possible with October or HTML(5)-friendly markup.
Also, since I'm not very sure I understood your desired output, you want to have a dropdown next to a checkbox. Is that correct? But how are the dropdown and checkbox related? Given the markup of a checkbox-typed input field, you cannot put anything inside it because it has no closing tag. A checkbox has HTML similar to this <input type="checkbox" name="foo" value="bar" />
.
What I am assuming is that you want the checkbox to activate the dropdown i.e., a checked checkbox shows the dropdown and an unchecked one doesn't?!
So, how ways to get value which selected in check box?Now, I create a tab menu then load value which selected and the last I insert to dropdown list. So, it's ok?
Still not sure what exactly you want to do but here's a few ways to getting the selected value of a checkbox. Assume you have the checkbox HTML as such
<input type="checkbox" name="cbxName" value="cbxValue" />
Then you can do the following
- Do it in jQuery whenever the user changes the checkbox. Code would be something like
$('#checkboxId').change(function( console.log($(this).val()); // log the value of the checkbox independent of its checked state here: 'cbxValue' console.log($(this).checked); // log true if checkbox now is checked, false otherwise ));
- Do it on the server side in a action function that you registered according to the docs
function update_onCheckboxChange() { $cbxVal = post('cbxName'); // is the value you have assigned if checkbox is checked here "cbxValue", otherwise this is NULL }
Note: a checkbox always has a value - defined by <input type="checkbox" name="cbxName" value="cbxValue" />
. I think what you are wanting to get though is the checked-state (or attribute) of the checkbox?!
Hi philipptempel,
How ways to insert each dropdown menu after each the check box list widget? Example:
Last updated
Now I see what you want and we are getting somewhere.
fields.yaml
should probably look something like this then
fields
cbxName[cbxValue1]:
type: checkbox
label: MANUALIDND
default: false
dropdown1:
type: dropdown
labeL: 'Instructional Design'
options:
test: test
cbxName[cbxValue2]:
type: checkbox
label: MANUALIDND
default: false
dropdown2:
type: dropdown
labeL: 'Instructional Design for New Designers Manual '
options:
test: test
cbxName[cbxValue3]:
type: checkbox
label: MANUALIDND
default: false
dropdown3:
type: dropdown
labeL: ' New Designers Manual'
options:
test: test
cbxName[cbxValue4]:
type: checkbox
label: MANUALIDND
default: false
dropdown4:
type: dropdown
labeL: 'Instructional Design'
options:
test: test
To my knowledge there is no other way to defining that than in that way. Note also, I haven't checked that code. Might still be a bit buggy but should lead you in the right direction. You might want to look into Triggering Events to show/hide the dropdowns depending on the associated checkbox being checked/unchecked.
PS: The markup you have used in your post will definitely lead to errors as you have the same value (and label) for all checkboxes. You might want to look into learning how to create a $_POST
-array from checkboxes. Maybe also you want to use the checkbox list provided by October and use the aforementioned Trigger Events to showing/hiding dropdowns.
As you can see there's multiple ways to solving your problem. It's all just a matter of defining your input fields properly and reading the docs to transform your requirements definition to a valid fields.yaml
definition.
Last updated
Hi philipptempel,
How ways to get checkbox array on database? I can't hard code as above I wanna run for syntax to get value from database, so please help me
tdphong15547 said: How ways to get checkbox array on database? I can't hard code as above I wanna run for syntax to get value from database, so please help me
Do you want to get the checkboxes from the database or input the selected values to the database? For the first, you need to extend the form in your controller before it is being rendered, for the latter you need to not do much but have the right $_POST
-key.
If you want to know how to use the Trigger Events, please read the section in the docs. It is well explained and even has examples.
Hi philipptempel ,
I'm created check box array as you said. I use it in get***Options function, but the octobercms have been generated:
Instructional Design for New Designers Manual <select name="type[1]"><option >elective</option><option >manditory</option><option >choice</option></select>
I'm checked and see syxtax: = e(trans($option[0])) ?> in Octobercms, Its do this. Please check help me about this. Thanks,Last updated
1-11 of 11