I am having two radio buttons namely users and groups.
If is select groups and refresh the browser it stays in groups itself.
When i give ctrl+f5 it's getting reset to users.
My need is:
While i click the refresh button in browser the radio button should be reset to users even it is selected as groups.
EDIT : CODE
$form['groups'] = array(
'#title' => t('Groups'),
'#type' => 'select',
'#multiple' => 3,
'#options' => $options,
);
$form['users'] = array(
'#type' => 'textfield',
'#title' => t('Users'),
'#description' => t('Separate multiple names with commas.'),
'#default_value' => '',
);
This is task developing using drupal and jquery..
Any help regarding this will be grateful and thankful...
Thanks in advance...
You can try this:
<html>
<head>
</head>
<body onload="clearItForm.reset();">
<form name="clearItForm">
<input type="radio" name="sweets">Ice Cream<br>
<input type="radio" name="sweets">Candy Bars<br>
<input type="radio" name="sweets">Milk Shakes<br>
</form>
</body>
</html>
An alternative to Robby Shaw's good answer is to reset the form outside of the html, in some JavaScript.
window.onload = function(){
clearItForm.reset();
}
Related
a division has a checkboxs and by clicking that checkbox radio buttons options need to be shown for a particular checkbox
checkbox is mapped as according to the array
<form id="lab_test_detail">
{item.subcategory.map((item, index) =>
<>
<input type={"checkbox"} onChange={() => handleChange(item, index)} name={item.id}></input>
<label style={{ position: "inherit", zIndex: "10" }}>{item.categoryname} </label>
<div id={index}></div>
</>
)}
</form>
when the checkbox is changed radio buttons option should have to populate on
handleChange is
const handleChange = (item, index) => {
httpClient.GET(`medical-institute/categoryId/${item.id}`, false, true)
.then(resp => {
// debugger;
document.getElementById(index).innerHTML =
`
${
resp.data.data.map((item1,index1)=>{
return`<form>
<input type="radio" onChange=${handleRadioChange(item,index)}></input>
<label >${item1.medicalinstitutename}</label>
<span> Rs.${item1.price}</span>
<br/>
</form>
`
})
}
`
console.log("response is", resp.data.data)
})
}
const handleRadioChange = (item, index) => {
console.log("inside radiochange")
console.log("dasdas", item, index)
}
so when radio button is clicked i need to do a particular thing but handleRadioChange is called when i click on the checkox but not when i click on radio , why is this happening, a ny solution?
Because you are executing the handleRadioChange once the node is added into the DOM.
Change the onChange handler
handleRadioChange(item,index)
to
() => handleRadioChange(item,index)
You should try to work with the virtual DOM instead of insert html string.
In your case, I think you can use state to store the item data for display and trigger the re-render. BTW you might don't have to fetch the data every time user clicks a check box.
I can not see starwidget in my yii2, I installed the widget, but it doesn't display stars.
See loading gif:
Following is my code:
echo '<label class="control-label">Rating</label>';
echo StarRating::widget([
'name' => 'rating_2',
'value' => 2.5,
'disabled' => true
]);
Is there an explanation to this. Please help!?
Check your js assets. Check if jQuery is not loading twice.
It was working perfectly, I have changed nothing, and I have realized that my AutoComplete widget is showing up not there where it was before (it was in the gridView, right underneath the filter textinput where it is expected). Now it shows up in the left upper corner of the page, with the first 2-3 options covered by the navbar. Is there a change in AutoComplete, or in Yii2 now? I have found an option appendTo that has maybe something to do with the problem, and I have done experiments with it but no luck, either it doesn't show up, or still on the wrong place. I have found nothing else relevant.
Here is my code in the gridview:
[
'attribute' => 'name',
'contentOptions' => ['nowrap' => 'nowrap'],
'filter' => AutoComplete::widget([
'model' => $searchModel,
'attribute' => 'name',
'clientOptions' => [
'source' => Pl::find()->allAutoCompleteName(),
'autoFill' => true,
],
'options' => ['class' => 'form-control']
]),
],
The id of the search field is plsearch-name
The js:
jQuery('#plsearch-name').autocomplete({"source":[{"value":"PE 150","label":"PE 150"}...],"autoFill":true});
If I'm setting the appendTo in clientOptions to '#plsearch-name', then it doesn't show up at all, however it is correct, isn't it? I don't see any styling in it.
What also quite interesting is:
<input
type="text"
id="plsearch-name"
class="form-control ui-autocomplete-input"
name="PlSearch[name]"
autocomplete="off"/>
What is this autocomplete="off" doing there?
Can you please point me to the right direction? Thanks a lot!
This Problem is fixed here: https://github.com/yiisoft/yii2-jui/commit/36468550d72bce9d963149abe85b13ea2f3a8c18
The JQuery UI Version should be updated to 1.12
"require": {
"yiisoft/yii2": "~2.0.4",
- "bower-asset/jquery-ui": "1.11.*#stable"
+ "bower-asset/jquery-ui": "~1.12.1"
},
i have form with two pjax. (one inside two) when clicked link in second PJAX send query to server but in field "X-PJAX-Container" write ID first container.
Pjax::begin([
'id' => 'register-form'
]);
...
Pjax::begin([
'id' => 'que'
]);
echo yii\helpers\Html::a('update', ['/portal/que/gr-usl/');
Pjax::end();
...
Pjax::end();
location after click update : /portal/que/gr-usl?_pjax=%23register-form
request header
X-PJAX:true
X-PJAX-Container:#register-form
X-Requested-With:XMLHttpRequest
if set data-pjax for link #que request header not changed.
for all link in inside pjax disabled data-pjax an href change to onclick with function
$.pjax({url: $(el).attr('link'), container: '#pjax-grusl'});
links has code
echo yii\helpers\Html::a('update', null,[
'data-pjax' => 'false',
'link' => \yii\helpers\Url::to(['/portal/que/gr-usl/',
'ids' => $ids,
'filter' => $filter,
'gr' => $gr
]),
'onclick' => 'selGr(this)'
]);
but its should work from box :( i don't understand why click by link don't find first pjax container from dom tree.
I am using the the Cake
<?= $this->Form->input('vehicles._ids', ['label' => 'Vehicle', 'options' => $vehicles, 'multiple' => 'checkbox', 'ng-model' => 'vehicles']); ?>
For each check box I want to add the custom attributes: 'ng-model'
I can see that the generation of multiple checkboxes is handled by the class file MultiCheckboxwidget.php and checkboxes use the 'checkbox' template:
'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',
But since by default this uses {{attrs}} I can't see why my custom ng-model attribute isn't being added to the generatred form input. Instead this is the amrk-up crearted by the helper:
<input type="checkbox" name="vehicles[_ids][]" value="1"id="vehicles-ids-1" class="ng-valid">
How can I add ng-model to each of the checkbox inputs?
Upgrading my verison of CakePHP form 3.3.12 to 3.4 resolved the issue, the formhelper must have been refined in the latter versions.