[EXTENSION] EMultiSelect
#2
Posted 16 May 2011 - 01:09 AM

When add to form..
$this->widget('application.widget.emultiselect.EMultiSelect', array('sortable' => true, 'searchable' => true) );
Change to..
$this->widget('application.extensions.emultiselect.EMultiSelect', array('sortable' => true, 'searchable' => true) );
EmultiSelect.php - Line #60
$basePath=Yii::getPathOfAlias('application.widget.emultiselect.assets');
Change to...
$basePath=Yii::getPathOfAlias('application.extensions.emultiselect.assets');
.. or ..
$resources = dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'; $basePath = Yii::app()->assetManager->publish($resources);
#3
Posted 16 May 2011 - 08:23 PM
#4
Posted 18 May 2011 - 08:43 AM
I am not sure how to go about getting the records to save. This is used to select tracks on a playlist.
My _form has the following code.
$tracks = Track::model()->findAll();
$data = array();
foreach ($tracks as $track)
$data[$track->idtrack] = $track->name . ' '. $track->idtrack;
echo $form->dropDownList(
$model,
'tracks',
$data,
array('multiple'=>'multiple',
'key'=>'tracks', 'class'=>'multiselect'));
$data contains a list of all idversions, displaying the name and idversion.
Should this be saved into a char() column? Should I save the list of idtracks on the tracks column? I am getting an error when I try and do this. The error is "Array to string conversion".
Any suggestions anyone? Clearly I am fairly new to this!
Thanks
#6
Posted 26 May 2011 - 10:08 PM
In which case, you would probably be using a manymany relation so this behavior can also help with saving: http://www.yiiframew...ons-ar-behavior
Then, Yii can autoselect things for you. (Use the key option for the dropdown.)
Eg In _form.php
<?php $post=Trainingo::model()->findAll(); $trainings = CHtml::listData($post, 'training_id', 'name'); // Get the list of options echo $form->dropDownList( $model, 'trainingosCall', $trainings, array( 'multiple'=>'multiple', 'key'=>'training_id', // The id from the table 'class'=>'multiselect', ) ); ?>
In model relations function:
'trainingosCall' => array( self::MANY_MANY, 'Trainingo', 'call_trainingo(call_id, trainingo_id)' ),
Note: I have a table call_trainingo with 2 columns call_id and trainingo_id to relate them.
Then to save (using the behavior above also):
$model->attributes=$_POST['Call']; if (!is_array(@$_POST['Call']['trainingosCall'])) { $_POST['Call']['trainingosCall2'] = array(); } $model->setRelationRecords( 'trainingosCall', $_POST['Call']['trainingosCall'] ); $model->save();
#7
Posted 25 June 2011 - 10:31 PM
One enhancement I was thinking about is a shortcut to creating additional items in the 'other' table of relations.
For example, lets use a MANY_MANY relationship of Posts and Categories.
When using eMultiSelect I can display a post with related categories and assign them dynamically on the fly. It would be nice to be able to add additional categories on the fly while doing the assignment in the post model.
I also have a 'categories' management in my app but trying to think of a good way to do this.. part of this extension or just a secondary form on the same page?
#8
Posted 26 June 2011 - 08:48 PM
dniznick, on 25 June 2011 - 10:31 PM, said:
One enhancement I was thinking about is a shortcut to creating additional items in the 'other' table of relations.
For example, lets use a MANY_MANY relationship of Posts and Categories.
When using eMultiSelect I can display a post with related categories and assign them dynamically on the fly. It would be nice to be able to add additional categories on the fly while doing the assignment in the post model.
I also have a 'categories' management in my app but trying to think of a good way to do this.. part of this extension or just a secondary form on the same page?
Thanks.
Let me make sure I understand first, you are basically wanting a way to add additional options (in your case categories) via AJAX (which would create the new option in the database and update the list)?
I think you would probably have to build that in yourself, though you might find an extension to make it work. You would need to have an AJAX handler in the controller and a field that could post the new category, then it would need to add the option to your dropdown and possibly refresh the multiselect thing to get it to update.
Alternatively, it might be easier to just use JS on the client side and then deal with the added options on save rather than adding them via AJAX. Then of course you would be validating later on the new options so you might run into some validation issues on the new category that you would have to handle.
I hope that make some since and helps a little. I will be happy to guide you as much as possible as you go, but I don't think I will be able to code it.
(As a side note, minus the refreshing of the jquery multiselect, this would be exactly the same as if you weren't using EMultiSelect because all I've done is change a JQuery addon to where it plays nicely with Yii Extensions.)
#9
Posted 30 June 2011 - 05:22 AM
It worked for me with MANY_MANY mode, when
- Set the foreign keys in the intermediate table. That was possible when
-- All related tables' ENGINE=InnoDB
-- There are only valid values in that table (or empty table)
Although obvious for most people, maybe it helps newcomers (like me)

#10
Posted 28 July 2011 - 12:52 AM
I want to update existing data with ajax.
data is changed, but not refreshed ..
I think want to put a trigger to click the remove-all so the results can be refreshed
is it possible?<br>and it is possible to add onchange???<br>
This post has been edited by Mr D: 29 July 2011 - 01:08 AM
Programmer: "That's no bug, that's just an undocumented feature!"
#11
Posted 29 July 2011 - 07:01 AM
You may have to modify my code somewhat to allow you to set
Their also appear to be a next version that supports AJAX
Quote
This is a more advanced but not well tested extended version of the jQuery UI Multiselect widget.
It just got updated to work along with jQuery 1.4.2 and jQuery UI 1.8.
I’ve installed a demo page at http://quasipartikel...ltiselect_next/
-
For the original version done by Yanick (which is based on jQuery 1.3 and jQuery UI 1.7) please visit his demo page:
http://yanickrochon....om/multiselect/
If you have suggestions or did some nice modifications just let us know.
We’d be happy to review them, and perhaps include them.
My addon essentially just wraps the jQuery plugin so feel free to see how that is done to wrap one of the other verisons or to use features out of this version.
#12
Posted 04 September 2011 - 09:33 PM
and 1 more
when I click the plus sign in a hurry, the value in Colom selected become duplicate

Number of downloads: 74
I run it in mozilla6.0
duplicate

Number of downloads: 74
Programmer: "That's no bug, that's just an undocumented feature!"
#13
Posted 05 September 2011 - 07:51 PM
Mr D, on 04 September 2011 - 09:33 PM, said:
and 1 more
when I click the plus sign in a hurry, the value in Colom selected become duplicate

I run it in mozilla6.0
duplicate

Yii has datepicker built in now so you should not need to use that extension.
http://www.yiiframew.../CJuiDatePicker
As far as the doubling goes. I cannot reproduce it on my system, but that is an error in the js of the extension so you can report that to the js extension creator here: http://www.quasipart...at/multiselect/
If he makes changes, please update me so I can correct the copy of his js in my code.
#14
Posted 12 September 2011 - 03:04 AM
Programmer: "That's no bug, that's just an undocumented feature!"
#16
Posted 25 March 2012 - 05:31 AM
now I have a height issue, the multiselect does not want to obey me

/* multiselect styles */ .multiselect { width: 660px; height: 400px; }
The width changes, but not the height. I've tried cleaning the root assets folder(where yii publishes everything).
Didn't work (was not required for the width to change anyway..)
So I inspected it with firebug and I've found the problem,
<ul class="selected connected-list ui-sortable" style="height:32px"> <ul class="available connected-list" style="height: 32px;">
Cant find though where these attributes come from, any idea?
#19
Posted 28 March 2012 - 01:31 AM

#20
Posted 28 March 2012 - 09:17 AM
I am displaying all Owners in the table so the user can populate userToOwner, but I'd also like to display all owners that are related to user(userToOwner) as selected. Is it possible?
Got it sorted, nevermind.
If you ever get this problem, just create an array of values to be selected, ie:
foreach($model->owners as $ownerID)
{
$array[$ownerID->ownerID] = array("selected"=>true);
}
and pass $array to options: 'options'=>$array