Is there any way to show pageSummary of all data even if there is pagination?
[
'attribute' => 'sale_total',
'pageSummary' => true,
'hAlign' => 'right',
'format' => ['decimal',2],
],
This shows only sum per page but I wanted it of all the data, not a particular page.
By Clicking the All(Show all data) link(On the right side toolbar options), the sum of all the records total will be displayed.
Try:
'summary' => {totalCount},
I'm not sure if this is what you are looking for.
Related
I am using yii2-formwizard and I want to insert a checkbox as form input field for the field is_legal in a tabular step.
So in fieldConfig array, reading the documentation, I inserted the following code:
'is_legal' => [
'options' => [
'type' => 'checkbox',
],
'labelOptions' => [
'label' => \Yii::t('app', 'Legal Representative'),
],
],
The following image shows the result:
However, when I go the preview step I see the field of the checkbox set as undefined:
In fact, when I try to save the model, the is_legal field is not set.
First Question: where is the problem with the checkbox form field?
Second Question: is there any way to customize the preview step? For example instead of 'Step 5', I would like to write 'Legal Data'.
i created this widget and there are a few things you need to know.
First Answer
The undefined it is showing is not the value but the label of the checkbox, if you look into the getLabel() function in the formwizard.js file it looks into the siblings of the input field for a label and gets its text
let text = $('#' + fieldName).siblings('label').text();
to display on the preview step, and by default Yii2 wraps the input inside the label like
<label><input stype="checkbox"></label>
so you need to use the template option of the checkbox like below
'is_legal' => [
'options' => [
'type' => 'checkbox',
'template' => '{input}{beginLabel}{labelTitle}{endLabel}{error}{hint}',
],
'labelOptions' => [
'label' => \Yii::t('app', 'Legal Representative'),
],
],
Second Answer
No, currently the widget does not support the custom title for the Preview step sections, but i think I can add the support for providing the title of the headings as it makes sense too, if that sorts your problem.
Update
Ignore the Second Answer given above i just pushed the updates to the live branch you can now use the previewHeading option in the step settings. Update your composer by running composer update to update to the latest version and clear cache using CTRL+F5.
See the following sample code how to use previewHeading option
use buttflattery\formwizard\FormWizard;
echo FormWizard::widget([
'enablePreview'=>true,
'steps'=>[
[
'model'=>$user,
'title'=>'My Shoots',
'previewHeading'=>'My Heading Step 1',
'description'=>'Add your shoots',
'formInfoText'=>'Fill all fields'
],
[
'model'=> $profile,
'title'=>'My Shoots',
'previewHeading'=>'My Heading Step 2',
'description'=>'Add your shoots',
'formInfoText'=>'Fill all fields'
],
]
]);
I have a tree node in my form. I am using kartik-v's Tree Manager.
This is my view code:
echo TreeViewInput::widget([
'query' => Tree::find()->addOrderBy('root, lft'),
'headingOptions' => ['label' => 'Set Permission'],
'name' => 'name',
'value' => '1,2,3',
'asDropdown' => false,
'multiple' => true,
'fontAwesome' => true,
'rootOptions' => [
'label' => '<i class="fa fa-tree"></i>',
'class' => 'text-success'
]);
But, in this I have to follow the same table structure as mentioned in the widget. I have some extra fields and more permissions. So it is a bit complicated to use the same structure.
Is it possible to pass the value in an array directly to this widget? If possible let me know the array format.
Now I am stuck with this tree node implementation.
You can do this by doing some tricks, or by using another way:
1) you can add a condition to your query like this:
Tree::find()->andWhere(['not in','id',[2,3,4]])->addOrderBy('root, lft'),
by this solution you can ignore unwanted rows like you send data direct in array...
2) you can use another solution by using js lib/plugin direct like jsTree, in this case you can create and pass custom array direct...look at this example: jsTree Example
I'm trying to display category values according to it's name, not id. I'm trying to do like so:
[
'attribute' => 'category_id',
'value' => 'category.name',
],
But then attribute doesn't get displayed. It displays: name instead of Category. Category name is displayed correctly.
Also tried 'category.name' ,but it's displaying same values, and 'category_id' is displaying label correctly, but the name - according to id's.
How should I solve that?
Are you define relation for category, like this?
public function getCategory()
{
return $this->hasOne(Category::className(),['id'=>'category_id']);
}
If you want to display in GridView, you can do it like you
[
'attribute' => 'category_id',
'value' => 'category.name',
],
If you want to display in DetailView, you can do it like this
[
'attribute' => 'category_id',
'value' => $model->category ? $model->category->name : '',
],
seems you need a label.
the simplest way is add the label direcly in the detail view item
[
'label' => 'Category',
'attribute' => 'category_id',
'value' => ....,
],
If I'm doing 'label' => false, it is still showing the empty cell of the label. Is it possible completely not to render label cell somehow? Many thanks!
UPDATE: 'labelColOptions' => ['hidden' => true] works!
You can use visible property :
For example,
[
'attribute' => 'name',
'value' => whatever,
'visible' => (!empty($model->name)),
]
I am working on an automated form submit script. It is logging in to a vendor's website and populating the fields of a form. When trying to submit, the desired result would be a ticket number displayed, which is acknowledging the form is submitted and the request is processed by their helpdesk.
However the form is not submitted correctly (no acknowledgement is displayed) and I suspect that it is caused by one of the inputs which is a SELECT.
Here is the code I use to set this field:
$forms[3]->value('ProductList','-2');
This has no effect on the the prepared form unfortunately, dumping $forms[3], i see this:
[...]
bless({
'onchange' => ' checkKC(document.all.ProductList, \'~0\'); prodExpand();',
'current' => 1,
'menu' => [
{
'seen' => 1,
'value' => '~0',
'name' => '<Please select>'
},
{
'seen' => 1,
'value' => '-2',
'name' => 'Product not found.... Search more'
},
{
'value' => '-1',
'name' => '------------------------------------'
},
{
'value' => 'Product1',
'name' => 'Product 1 Name'
}
],
'name' => 'ProductList',
'id' => 'ProductList',
'idx' => 1,
'type' => 'option'
}, 'HTML::Form::ListInput' ),
[...]
Am I using the right method of $forms[3]? (it was created by HTML::Form->parse($pageresult) btw) Or is there any other method I should try? I can't find any documentation for HTML::Form::ListInput
Thanks for any advice
Consider using WWW::Mechanize for form processing that takes more than one step. That way you can include the login process in your script along with going to the form and of course getting the result.
Or if you need to work with JavaScript, then use WWW::Mechanize::Firefox.