I am using XMultiSelects Widget to post large data in form.(Yii Framework)
<div class="row">
<?php echo $form->labelEx($model, 'list'); ?>
<div style="display: inline-block">
<?php
$this->widget('multiselects.XMultiSelects', array(
'id' => 'hd-programs', //since there are multiple selector pairs on this page we need to set identifier
'leftTitle' => 'Available',
'leftName' => 'availableList',
'leftList' => $availableList,
'rightTitle' => 'Selected',
'rightName' => get_class($model) . '[list][]',
'rightList' => $list,
'size' => 15,
'width' => '350px',
));
?>
<?php echo $form->error($model, 'list'); ?>
</div>
where $avaliableList is very large data set.
Now when i print value of form using print_r($_Post['MyFormName']) $list is not posted.
Any suggestion how could i handle large data with multiselect widget.
Related
<?php
$business=$model->reviewBusinesses;
foreach ($business as $business) {
$c = $business->rating; ?>
<div class="ratings"> <!--use class in order to show rating horizontally -->
<?php
$this->widget('ext.DzRaty.DzRaty', array(
'name' => 'rating',
'value' => $c,
'options' => array(
'readOnly' => TRUE,
),
));
?>
</div>
<?php } ?>
I am working in yii and using dzraty extension for star rating. In one of my view file which is userbusiness.php of business table which has relationship with revewbusiness table. I am getting rating from reviewbusiness table and showing it in one of my view file of business as mentioned above. I am getting rating in numeric form, but from above code i can only get rating of 1st review in star form while the rest of the rating is coming in numeric form. Can someone find my error?
like this
first_star second_star third_star fourth_star fifth_star
2
3
4
5
For those who really want to understand, in reviewbusiness table, i am getting rating, reviews of users.
Try this (you are using business as data set and as key at the same time):
<?php $business = $model->reviewBusinesses;
$i = 0;
foreach ($business as $business_key) {
$c = $business_key->rating;
?>
<div class="ratings"> <!--use class in order to show rating horizontally -->
<?php
$this->widget('ext.DzRaty.DzRaty', array(
'name' => 'rating_'.$i,
'value' => $c,
'options' => array(
'readOnly' => TRUE,
),
'htmlOptions' => array(
'id' => 'rating_'.$i,
),
)); ?>
</div>
<?php
$i++;
}
?>
I have 3 dependent dropdowns, and a textfield being dependent to the last dropdown. If one of the value in the last dropdown, I want the textfield value dynamically changes based on the selected value (it's from the same Database table).
This is the view of the third dropdown:
<div class="row" id="id_subkeg">
<?php echo $form->labelEx($model, 'id_subkeg'); ?>
<?php
echo $form->dropDownList($model, 'id_subkeg', array(), array(
'style' => 'width: 100%',
'ajax' => array(
'type' => 'POST',
'url' => CController::createUrl('dynamicSatuan'),
'update' => '#' . CHtml::activeId($model, 'satuan'),
//'update'=>'#seksi',
'data' => array('id_subkeg' => 'js:this.value'),
)
)
);
?>
<?php echo $form->error($model, 'id_subkeg'); ?>
</div>
This is the textfield view:
<div class="row" id="satuan">
<?php echo $form->labelEx($model, 'satuan'); ?>
<p class="hint" style="font-size: 80%">Contoh: Dokumen.</p>
<?php echo $form->textField($model, 'satuan', array('style' => 'width: 98%;', 'readonly' => FALSE)); ?>
<?php echo $form->error($model, 'satuan'); ?>
</div>
And this is the action in the controller:
public function actionDynamicSatuan() {
//$data = Subkegiatan::model()->findByPk($_POST['id_subkeg']);
$data = Subkegiatan::model()->findByPk('id_subkeg=:id_subkeg', array(':id_subkeg' => (int) $_POST['id_subkeg']));
echo $data->satuan;
}
But it's not been working for days. I don't know which part I've missed. My guess is that the dropdown is a dependent dropdown to the one above it. So I must have missed at some part.
Any help is highly appreciated.
UPDATE:
After days of searching, finally got it:
public function actionDynamicSatuan() {
$param_country = (int) $_POST['id_subkeg'];
$maxOrderNumber = Yii::app()->db->createCommand()
->select('satuan')
->from('subkegiatan')
->where('id_subkeg = ' . $param_country)
->queryScalar();
echo '<b>SATUAN: '. $maxOrderNumber.'</b>';
//echo CHtml::tag('input', array('type' => 'text', 'value' => $maxOrderNumber));
}
Instead of update, use success callback:
echo $form->dropDownList($model, 'id_subkeg', array(), array(
'style' => 'width: 100%',
'ajax' => array(
'type' => 'POST',
'url' => CController::createUrl('dynamicSatuan'),
'data' => array('id_subkeg' => 'js:this.value'),
'success'=> 'function(data) {
$("#your_id_here").empty();
$("#your_id_here").append(data);
}'
)
)
);
I am new to drupal.
I need to customize a registration form by adding fields like id,mobile etc.
Can I accomplish this by creating a custom module?
If yes could anyone please help me with a brief idea on creating and overriding the default user registration submit function. I have to insert these details to another table and also have to pass the data as a service request.
Ive created a custom module with function
module_form_alter(&$form,&$form_state,$form_id){
$form['#submit'] = 'module_form_submit';
if($form_id == 'user_register_form'){
//print_r($form_id);
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('id'),
'#default_value' => '',
'#size' => 60,
'#maxlength' => 15,
'#required' => TRUE,
);
}
}
function module_form_submit($form, &$form_state){
echo "test";
exit();
}
module_form_alter is being called and I can see the new field on the registration screen but the submit function is still not called. I need to override the default drupal register submit.
I already have the following function in my theme template.php
function templatename_theme() {
$items = array();
$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'portal') . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'portal_preprocess_user_login'
),
);
$items['user_register_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'portal') . '/templates',
'template' => 'user-register-form',
'preprocess functions' => array(
'portal_preprocess_user_register_form'
),
);
$items['user_pass'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'portal') . '/templates',
'template' => 'user-pass',
'preprocess functions' => array(
'portal_preprocess_user_pass'
),
);
return $items;
}
user-register-form.tpl.php
<div class="form-group">
<?php print drupal_render_children($form); ?>
</div>
And page--user--register.tpl.php with the html
<div id="login-page">
<div class="container">
<div class="form-login" >
<h2 class="form-login-heading"><img src="<?php echo drupal_get_path('theme', 'portal') . '/images/logo.png'; ?>" width="100"><?php echo $createaccount; ?></h2>
<div class="login-wrap">
<?php
$elements = drupal_get_form("user_register_form");
$form = drupal_render($elements);
echo $form ?>
<?php if ($messages):?>
<div id="messages-console" class="clearfix">
<div class="grid_12">
<div class="mt-grid-fix">
<?php print $messages; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
Is this approach fine or should I change this approach inorder to make my custom module functional?
You can go to:
admin/config/people/accounts/fields
and add the fields that you need.
In the fieldset "User settings" don't forget check "Display on user registration form."
How would i get the current pagesize in my View? I want to be able to add a banner when half the pagesize is reached.
If the page size is 10, insert a banner at position 5
i tried adding this in my view.php
if ($index == ($dataProvider->pagination->pageSize / 2)) { ... }
and this my index.php
$this->widget ( 'site.common.extensions.EListView.EListView', array (
'dataProvider' => $dataProvider,
'itemView' => '_view_gallery',
'pagerCssClass' => 'pagination',
'template' => '
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<div class="pull-right">{sorter}</div>
<div class="pull-left"></div>
</div>
</div>
<div class="row">
<div class="col-md-12">{items}</div>
</div>
<div class="row padding-top-20px">
<div class="col-md-12">
{pager}
</div>
</div>
</div></div>',
'pager' => array (
'id' => '_pagination',
'class' => 'LinkPager',
'header' => '',
'htmlOptions' => array (
'class' => 'pagination'
)
),
'emptyText' => '<div class="alert alert-info">No result found.</div>'
)
);
but nothing happens.
I'm currently using this extension to create a perpage page size.
http://www.yiiframework.com/extension/elistview
also tried without using this extension, but still no luck. I'm using Yii 1.1.16.
any ideas?
In your _view_gallery.php you can use special variables available for CListView and CGridView (http://www.yiiframework.com/wiki/252/special-variables-in-cgridview-and-clistview/) in order to get the pageSize.
That could look like this:
if($widget->dataProvider->pagination->pageSize == 10){
//do something here
}
Accessing $dataProvider directly won't result in anything because that variable means nothing to the view.
I want to pass a php variable to modal window , what i am doing is opening a modal window using this link , but i want to pass a variable to this link and get same variable in modal window , i try to to do this to append a text in some div but it return html that i am unable to get in query
echo CHtml::link(
'Set Recipe', '', array(
'class' => 'testclass',
'id' => $finalDate,
'data-toggle' => 'modal',
'data-target' => '#myModal',
'fahadVar' => $finalDate
));
and when i click this button i got modal window how to get variable set in button
Here is simple modal code of yiibooster
<div class="modal-body">
<p>One fine body...</p>
</div>
<div class="modal-footer">
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'type' => 'primary',
'label' => 'Save changes',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Close',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
</div>
<?php $this->endWidget(); ?>
thanks in advance
You should create a Widget.
Note: I copied below from another post. It works like charm.
First Create a new widget. Let say the name is CategoryWidget. Put this widget under components directory protected/components.
class CategoryWidget extends CWidget {
public function run() {
$models = Category::model()->findAll();
$this->render('category', array(
'models'=>$models
));
}
}
Then create a view for this widget. The file name is category.php. Put it under protected/components/views
category.php
<?php if($models != null): ?>
<ul>
<?php foreach($models as $model): ?>
<li><?php echo $model->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Then call this widget from your main layout.
main.php
// your code ...
<?php $this->widget('CategoryWidget') ?>