Here I've array of text boxes set belongs to one.
$this->addElement('text', '1', array(
'label' => 'Text One',
'belongsTo' => 'txtarray'
));
$this->addElement('text', '2', array(
'label' => 'Text Two',
'belongsTo' => 'txtarray'
));
$this->addElement('text', '3', array(
'label' => 'Text Three',
'belongsTo' => 'txtarray'
));
I want to add these all to one display Group
$this->addDisplayGroup(array('txtarray'), 'pcinfo', array('legend' => 'Other Block'));
But this is not working.
How is that possible to add group of array Elements to display group?
Try this:
$this->addElement('text', '1', array(
'label' => 'Text One',
));
$this->addElement('text', '2', array(
'label' => 'Text Two',
));
$this->addElement('text', '3', array(
'label' => 'Text Three',
));
and then:
$this->addDisplayGroup(array('1','2','3'), 'pcinfo', array('disableLoadDefaultDecorators' => true,'legend' => 'Other Block'));
And don't forget to add these lines:
$this->setDisplayGroupDecorators(array(
'FormElements',
'Fieldset'
));
You can visit this blog ,you will get great help
http://zendgeek.blogspot.in/2009/07/zend-form-display-groups-decorators.html
Related
How to add hidden values or insert values to fields that are not exposed to user such as date_add and date_upd when Using the HelperForm class in PRESTASHOP 1.6.3
I created a new module and now there are two fields in my table which need to be inserted when a new add happens and when an update is done by the user but how to do this when I am using HelperForm class in PRESTASHOP
Below is my render form script
// This form is populated when add or edit is clicked
public function renderForm()
{
$years = Tools::dateYears();
$months = Tools::dateMonths();
$days = Tools::dateDays();
$ticketSeries = Winners::getTicketSeries();
$prdtCategory = Winners::getProductCategory();
$nationality = Winners::getNationality();
$this->fields_form = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Configure your Winner'),
'icon' => 'icon-user'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name'),
'name' => 'name',
'required' => true,
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()##"°{}_$%:'
),
array(
'type' => 'text',
'label' => $this->l('Ticket No'),
'name' => 'ticket_no',
'required' => true,
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()##"°{}_$%:'
),
array(
'type' => 'select',
'label' => $this->l('Ticket Series'),
'name' => 'series',
'required' => true,
'options' => array(
'query' => $ticketSeries,
'id' => 'ticket_series_name',
'name' => 'ticket_series_name'
),
'col' => '4',
'hint' => array(
$this->l('The ticket series of each draw !!.')
)
),
array(
'type' => 'select',
'label' => $this->l('Category'),
'name' => 'category',
'required' => true,
'options' => array(
'query' => $prdtCategory,
'id' => 'name',
'name' => 'name'
),
'col' => '4',
'hint' => array(
$this->l('Product Category.')
)
),
array(
'type' => 'date',
'label' => $this->l('Draw Date:'),
'name' => 'draw_date',
'size' => 10,
'required' => true,
'desc' => $this->l('The draw date of this series'),
),
array(
'type' => 'select',
'label' => $this->l('Nationality'),
'name' => 'nationality',
'required' => true,
'options' => array(
'query' => $nationality,
'id' => 'name',
'name' => 'name'
),
'col' => '4',
'hint' => array(
$this->l('Nationality the winner Belongs .')
)
),
array(
'type' => 'textarea',
'label' => $this->l('Testimonial'),
'name' => 'testimonial',
'required' => true,
'autoload_rte' => true,
'rows' => 7,
'cols' => 40,
'hint' => $this->l('Invalid characters:').' <>;=#{}'
), // add tag 'autoload_rte' => true, 'lang' => true, --> lang i removed
// since the editor value did not submit editor
)
);
//d(Tools::getIsset('update'));
if (Tools::getIsset('add') )
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Add Date'),
'name' => 'date_add',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()##"°{}_$%:'
))
));
if (Tools::getIsset('update'))
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Update Date'),
'name' => 'date_upd',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;? =+()##"°{}_$%:'
))
));
$this->fields_form['submit'] = array(
'title' => $this->l('Save'),
);
$this->addJqueryUI('ui.datepicker');
return parent::renderForm();
}
I tried something like below yet no use
if (Tools::getIsset('add') )
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Add Date'),
'name' => 'date_add',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()##"°{}_$%:'
))
));
if (Tools::getIsset('update'))
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Update Date'),
'name' => 'date_upd',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;? =+()##"°{}_$%:'
))
));
use 'type' => 'hidden' and provide the value with, for example, 'value' => date("Y-m-d H:i:s")
I'm trying to change a column name of CGridView.
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'package-days-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'id',
'package_id',
'description',
array(
'name' => 'My description',
'value' => 'description'
),
array(
'class' => 'CButtonColumn',
),
),
));
?>
I need to add title 'My description' to 'description' column but I'm getting this error
Property "PackageDays.My description" is not defined.
Seems you want change the header not the name try this way
'header'=>'My description',
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'package-days-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'id',
'package_id',
'description',
array(
'name' => 'description',
'header' = => 'My Description',
// 'value' => 'description' don't need no more
),
array(
'class' => 'CButtonColumn',
),
),
));
?>
i want to show already selected values in tags of ESelected extension but unable to find any solution my code in update form in view is
$this->widget('ext.select2.ESelect2', array(
'name' => 'cat_names[]',
'data' => Coupon::getCategories(),
'options' => array(
'placeholder' => '',
'allowClear' => true,
),
'htmlOptions' => array(
'multiple' => 'multiple',
),
));
if i add tags fields in option of Eselect it changes the behaviour and stop working i add tags in options like this
'tags' => Coupon::getCategories_old(),
Any suggestion will be helpfull thanks in advance
$this->widget('ext.select2.ESelect2', array(
'name' => 'cat_names[]',
'value'=> array(91,95),
'data' => Coupon::getCategories(),
'options' => array(
'placeholder' => '',
'allowClear' => true,
),
'htmlOptions' => array(
'multiple' => 'multiple',
),
));
Model--
enter code here
public function searchShop()
{
$criteria = new CDbCriteria();
$criteria->compare("name", $this->category, TRUE, "OR");
$criteria->compare("shopname", $this->category, TRUE, "OR");
$criteria->compare("category", $this->category, TRUE, "OR");
return Shops::model()->findAll($criteria);
}
code----
enter code here
<?php
foreach($models as $model):
$this->widget(
'bootstrap.widgets.TbDetailView',
array(
'type'=>'bordered condensed',
'data' => array(
'id' =>array('view', 'id'=>$model->ID),
'Shop Name' => $model->shopname,
'Category' => $model->category,
'ID' => CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID))
),
'attributes' => array(
array('name' => 'Shop Name', 'label' => 'Shop name'),
array('name' => 'Category', 'label' => 'Category'),
array('name' => 'ID', 'label' => 'ID'),
),
)
);
echo "<br><hr><br>";
endforeach;
?>
I want a link on ID by clicking on it it will render view file i.e view.php of shops model
I used CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID)) but it is showing path of that view as 1
help me...
thanks in advance
try
CHtml::link(CHtml::encode($model->ID),
CController::createUrl('site/view',array('id'=>$model->ID)))
here i have assumed that action view lies in site controller. If it lies under some other module name then you can write like this "moduleName/controllerName/actionName"
Edit:
Ok you have to try a few things. TbDetailView extends CDetatilView. Now you can use TbDetailView as
$this->widget(
'bootstrap.widgets.TbDetailView',
array(
'type'=>'bordered condensed',
'data' => array(
'id' =>array('view', 'id'=>$model->ID),
'Shop Name' => $model->shopname,
'Category' => $model->category,
),
'attributes' => array(
array('name' => 'Shop Name', 'label' => 'Shop name'),
array('name' => 'Category', 'label' => 'Category'),
array('label' => 'ID', 'value' => CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID))),
),
)
);
You can also do like
$this->widget(
'bootstrap.widgets.TbDetailView',
array(
'type'=>'bordered condensed',
'data' =>$model,
'attributes' => array(
array('name' => 'shopname', 'label' => 'Shop name'),
array('name' => 'category', 'label' => 'Category'),
array('value' => CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID))
),, 'label' => 'ID'),
),
)
)
;
Given tbbuttongroup when user clicks the items I want to open a link to new blank page. I've tried the code below but it doesn't work.
<?php
$this->widget(
'bootstrap.widgets.TbButtonGroup',
array(
'type' => 'primary',
// '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'),
array(
'items' => array(
array(
'label' => 'Cetak ke Pdf',
'url' => array("Tbpinjaman/cetakpdf",id=>$_GET[id]),
'target'=>'_blank',
),
array('label' => 'Export ke Excel', 'url' => 'Tbpinjaman/admin'),
)
),
),
)
);
<?php
$this->widget(
'bootstrap.widgets.TbButton', array(
'url'=> 'http://stackoverflow.com/',
'label'=>Yii::t('strings', 'stackoverflow'),
'htmlOptions' => array('target'=>'_blank')
));
?>
target on button widget must be put on htmloptions :
'htmlOptions' => array('target'=>'_blank')
Use linkOptions for your anchor items
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/cetakpdf/$_GET[id]','Your window name','width=500,height=700'); return false;"
)
Your code will come like this.
<?php
$this->widget('bootstrap.widgets.TbButtonGroup', array
(
'type' => 'primary',
'buttons' => array
(
array('label' => 'Action', 'url' => '#', 'htmlOptions' => array('id' => 'buttonStateful'),),
array
(
'items' => array
(
array
(
'label' => 'Cetak ke Pdf',
'url' => '#',
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/cetakpdf/$_GET[id]','Your window name','width=500,height=700'); return false;"
)
),
array
(
'label' => 'Export ke Excel',
'url' => '#',
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/admin','Your window name','width=500,height=700'); return false;"
)
)
)
)
)
));
?>
Try this :
<?php
$this->widget(
'bootstrap.widgets.TbButtonGroup',
array(
'type' => 'primary',
// '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'),
array(
'items' => array(
array(
'label' => 'Cetak ke Pdf',
'url' => array("Tbpinjaman/cetakpdf",id=>$_GET[id]),
**'htmlOptions' => array('target'=>'_blank'),**
),
array('label' => 'Export ke Excel', 'url' => 'Tbpinjaman/admin'),
)
),
),
)
);