I'm trying to put the
class="answer_class"
inside all of my checkboxes, however it is creating a div instead and placing the checkboxes there. What should I alter in my code to do what I intend?
$question['question_id'] => array(
'type'=>'select',
'multiple'=>'checkbox',
'options'=> $answers,
'class'=> 'answer_class',
'label' => false
)
You can pass attributes to the options for your checkboxes:-
$question['question_id'] => [
'type' => 'select',
'multiple' => 'checkbox',
'options'=> [
'value' => 1, 'text' => 'Foo', 'class' => 'class1',
'value' => 2, 'text' => 'Bar', 'class' => 'class2'
],
'label' => false
];
Related
I've been looking into this all day, and I'm just wondering if there is built in functionality for Kartik EditableColumn in regards to inputType.
While one can easily apply the SwitchInput to filterType - I can't seem to find a way to handle it in column. It is simply a boolean that I would like handled by this toggle.
While this code produces what I am looking for (aesthetically), I can't produce the expected functionality without strapping it to some JS.
[
//'class' => 'kartik\grid\EditableColumn',
'label' => 'Public',
'hAlign' => 'center',
'vAlign' => 'middle',
'mergeHeader' => true,
'format' => 'raw',
'value' => function ($model) {
return SwitchInput::widget([
'name' => 'test',
'value' => $model->public,
'pluginOptions' => [
'size' => 'mini',
'onText' => 'ON',
'offText' => 'OFF',
],
'labelOptions' => ['style' => 'font-size: 12px;'],
]);
}
],
Produces:
I have this gridview
I want to replace the blank space on the status with All, so that it will have All, Active, Inactive
View:Gridview
[
'class' => '\pheme\grid\ToggleColumn',
'contentOptions' => ['class' => 'text-center'],
'attribute'=>'is_status',
'enableAjax' => false,
'filter'=>['1'=>'InActive', '0'=>'Active'],
],
How do I achieve this?
Use filterInputOptions
[
'class' => '\pheme\grid\ToggleColumn',
'contentOptions' => ['class' => 'text-center'],
'attribute' => 'is_status',
'enableAjax' => false,
'filter' => ['1' => 'InActive', '0' => 'Active'],
'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => 'All'],
],
I use jlorente remainingcharacters widget to show remaining character countdown for Inputfield in _form.php:
<?= $form->field($model, 'char52', ['showLabels'=>true])->widget(\jlorente\remainingcharacters\RemainingCharacters::classname(), [
'type' => \jlorente\remainingcharacters\RemainingCharacters::INPUT_TEXTAREA,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'counter',
'invalidClass' => 'error'
],
'options' => [
'rows' => '1',
'class' => 'col-md-12',
'maxlength' => 52,
'placeholder' => Yii::t('app', 'Write something')
]
]) ?>
<?= $form->field($model, 'text', ['showLabels'=>true])->widget(\dosamigos\ckeditor\CKEditor::className(), [
'options' => ['rows' => 1],
'preset' => 'full'
]) ?>
As I rendered form fields the height of textInput is not the same as standard.
Is there any solution for this problem.
I am also searching for other widgets for remaining charachters as I want to use kartik\form\ActiveForm for rendering on the same text input remaining charachter count and ActiveField Prepend Addon.
Try adding "form-control" class to your widget:
'options' => [
...
'class' => 'col-md-12 form-control',
...
]
How can i make this input type with number. I mean when the page is opened in mobile phone, it'll be open the number keyboard.
[
'class'=>'kartik\grid\EditableColumn',
'headerOptions' => ['style' => 'width:10%', 'class'=>'text-center'],
'editableOptions'=>[
'asPopover' => false,
'inputType'=>\kartik\editable\Editable::INPUT_TEXT,
// Change here:
'editableValueOptions'=>['type'=>'number']
],
'attribute'=>'quantity',
'label'=>'Quantity',
],
EDIT ->> add 'editableValueOptions'=>['type'=>'number']
Use editableValueOptions. As the documentation says:
editableValueOptions: array, the HTML attributes for the editable value displayed.
[
'class'=>'kartik\grid\EditableColumn',
'headerOptions' => ['style' => 'width:10%', 'class'=>'text-center'],
'editableOptions'=>[
'asPopover' => false,
'inputType'=>\kartik\editable\Editable::INPUT_TEXT,
// Change here:
'editableValueOptions'=>['type'=>'number']
],
'attribute'=>'quantity',
'label'=>'Quantity',
],
'attribute' => 'quantity',
'class' => 'kartik\grid\EditableColumn',
'editableOptions'=>[
'valueIfNull' => 'not set',
'inputType' => \kartik\editable\Editable::INPUT_HTML5,
'options' => [
'type' => 'number',
'min' => '0.5',
'step' => '0.5',
],
],
You should use options array as shown above
I am using kartik datepicker extension http://demos.krajee.com/widget-details/datepicker in Yii2.
Issue :
If I use this with custom id for input it does not show show model validations
echo kartik\date\DatePicker::widget([
'model' => $objPatientModel,
'form'=>$objActiveForm,
'attribute' => 'date_of_birth',
'options' => ['placeholder' => 'Enter birth date ...', 'id' => 'patient_dob'], **// with id clientside validations for model does not work**
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'endDate' => date('d-m-Y'),
]
]);
While below code works
echo kartik\date\DatePicker::widget([
'model' => $objPatientModel,
'form'=>$objActiveForm,
'attribute' => 'date_of_birth',
'options' => ['placeholder' => 'Enter birth date ...'],**//id is not used here**
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'endDate' => date('d-m-Y'),
]
]);
But I want to use custom id .Any suggestions ?
You have to override the selectors, example:
$form->field($model, 'comment', ['selectors' => ['input' => '#myCustomId']])
->textarea(['id' => 'myCustomId']);?>
See https://github.com/yiisoft/yii2/issues/7627
<?=
$form->field($model, 'sales_date')->widget(DateControl::classname(), [
'name' => 'sales_date',
'value' => date('d-m-Y h:i:s'),
'type' => DateControl::FORMAT_DATETIME,
'autoWidget' => true,
'displayFormat' => 'php:d-m-Y h:i:s',
'saveFormat' => 'php:Y-m-d h:i:s',
'saveOptions' => [
'type' => 'hidden',
'form' => 'sales-form-red',
],
])
?>
by using the following option you can add extra form tag to input
'saveOptions' => [
'type' => 'hidden',
'form' => 'sales-form-red',
'class' => 'sales_date',
]
In my case out was
<input type="hidden" id="sales-sales_date" name="Sales[sales_date]" form="sales-form-red">
check by using link
Date Control Demo