I am using ‘bootstrap.widgets.TbEditableDetailView’ and in the data I want to user to be able to select I want the data in alphabetical order.
$this->widget('bootstrap.widgets.TbEditableDetailView', array(
'id' => 'contractor-details',
'data' => $model,
'htmlOptions'=>array('class'=>'table table-bordered table-striped table-hover','style' => 'width:500px;margin-left: 130px;',),
'url' => $this->createUrl('contractors/editable'), //common submit url for all editables
'attributes'=>array(
'name'=>'business_name',
array(
'name'=>'trade_title',
'headerHtmlOptions' => array('style' => 'width: 1000px'),
'value'=>TradeTitle::model()->findByPk($model->trade_title)->name,
'editable'=>array(
'type'=>'select',
'autotext'=>'auto',
'inputclass' => "span4",
'source'=>CHtml::listData(TradeTitle::model()->findAll(array('order' => 'name')), 'id', 'name'))),
It is the trade_title I want to order - I can get it in alphabetical order if I use
'source'=>CHtml::listData(TradeTitle::model()->findAll(array('order' => 'name')), 'name', 'name')))
The problem is that the list is from another model (trade_title) and I need the ‘id’ from this table to place into the ‘contractors’ table. Normally with a DropDownList this code would work but with TbEditableDetailView it will not order - it will only list in the same order as it appears in the trade_title table (which is the primary key obviously). There is 100+ trades to choose from and I could create a manual list but really that seems a long winded way of doing it.
I would appreciate any suggestions.