Yii Framework Forum: Yiibooster - Yii Framework Forum

Jump to content

  • (16 Pages)
  • +
  • « First
  • 4
  • 5
  • 6
  • 7
  • 8
  • Last »
  • You cannot start a new topic
  • This topic is locked

Yiibooster Make it gorgeous. Do it Fast. Rate Topic: ***** 6 Votes

#101 User is offline   tomsea 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 25-November 11

Posted 19 November 2012 - 11:30 PM

Hello! how can one use the Typeahead (bootstrap.widgets.TbTypeahead) OR CJuiAutoComplete to have autocomplete feature on related models (foreign key one-to-many relation)?

This is a very common scenario.

For example, when you have the following models and fields::

User.id_city

City.id
City.name

User.id_city is a foreign key to City.id


I'd like to do something similar to the following:

$this->widget('bootstrap.widgets.TbTypeahead', array(
    'model'=>$model, // instance of model 'User'
    'attribute'=>'id_city', // foreign key field
    'options'=>array(
        'source'=>City::model()->findAll(),
        'valueAttribute'=>'id', // city.id
        'displayAttribute'=>'name', // city.name
        'items'=>4,
        'matcher'=>"js:function(item) {return ~item.toLowerCase().indexOf(this.query.toLowerCase());}",
        )
    )
));


In other words, similar to how you can use the traditional drop-down list:

<?php echo $form->dropDownList($model, 'id_city', CHtml::listData(City::model()->findAll(), 'id', 'name')); ?>


...but with autocomplete feature.

How can this be done? Thank you.

UPDATE:

After reading a lot of forum posts, I can see that Typeahead and CJuiAutoComplete were not designed to work with "value and display" attributes of related models so you can use the required value/id of a selected display/name to submit for model creation/update.

Typeahead and CJuiAutoComplete seem to behave like "simple" autocomplete textboxes and I couldn't see an easy way to implement the value/display attributes behavior.

Fortunately for me, I found the select2 extension and it was as simple as copying the extension folder and using the following in a view:

<?php $this->widget('ext.select2.ESelect2',array(
	'model'=>$model,
	'attribute'=>'id_city',
	'data'=>CHtml::listData(City::model()->findAll(), 'id', 'nombre'),
)); ?>


Simple code to implement, works fine and looks nice.

Just wanted to share what I used as a solution.
0

#102 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 20 November 2012 - 02:53 AM

View Postdeez, on 07 November 2012 - 12:35 PM, said:

Hey Antonio,

Awesome extension man, this has the potential to take my project to the next level and I really appreciate all the work both you and Chris have put into it.

Regarding StickyTableHeaders (with filters),

My tbody collapses when the sticky header is active. I also noticed that the booster site has the same problem. You know a way to fix this? I tried tbody: min-width and width, neither seems to affect the collapsing problem.

Thanks again for all your hard work.


Could you tell me what is the browser you are using? I found my self having to modify some of the jquery plugins used, maybe this is one of the cases
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#103 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 20 November 2012 - 02:55 AM

View Postdeez, on 07 November 2012 - 06:26 PM, said:

@Kinetik - You need to upgrade your version of the framework. I was using 1.1.11 and got the same error, once I upgraded to 1.1.12 that error went away.

@Antonio

Please disregard my previous comment about the table headers as I just set column width on most columns and lined it up manually.

But I would like to know... Is it possible to use multiple picker columns or multiple relational Data Columns in the same grid?

If so, how would you do?


You have to set the class as per column configuration, use the example at the yiibooster site per each column, it shouldn't be a problem, is just a column class
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#104 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 20 November 2012 - 02:56 AM

View Postbatusa, on 09 November 2012 - 11:09 AM, said:

How can I do a form with one or more fields per row. For example:

Posted Image

Because I've only can do with one field per row. How can I put and align more than one field per row? Anyone help me please!


You will have to render the form yourself using the required widgets per position as your layout is a combination of the bootstrap grid system and forms vertical.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#105 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 20 November 2012 - 03:06 AM

View Posttomsea, on 19 November 2012 - 11:30 PM, said:

Hello! how can one use the Typeahead (bootstrap.widgets.TbTypeahead) OR CJuiAutoComplete to have autocomplete feature on related models (foreign key one-to-many relation)?

This is a very common scenario.

For example, when you have the following models and fields::

User.id_city

City.id
City.name

User.id_city is a foreign key to City.id


I'd like to do something similar to the following:

$this->widget('bootstrap.widgets.TbTypeahead', array(
    'model'=>$model, // instance of model 'User'
    'attribute'=>'id_city', // foreign key field
    'options'=>array(
        'source'=>City::model()->findAll(),
        'valueAttribute'=>'id', // city.id
        'displayAttribute'=>'name', // city.name
        'items'=>4,
        'matcher'=>"js:function(item) {return ~item.toLowerCase().indexOf(this.query.toLowerCase());}",
        )
    )
));


In other words, similar to how you can use the traditional drop-down list:

<?php echo $form->dropDownList($model, 'id_city', CHtml::listData(City::model()->findAll(), 'id', 'name')); ?>


...but with autocomplete feature.

How can this be done? Thank you.

UPDATE:

After reading a lot of forum posts, I can see that Typeahead and CJuiAutoComplete were not designed to work with "value and display" attributes of related models so you can use the required value/id of a selected display/name to submit for model creation/update.

Typeahead and CJuiAutoComplete seem to behave like "simple" autocomplete textboxes and I couldn't see an easy way to implement the value/display attributes behavior.

Fortunately for me, I found the select2 extension and it was as simple as copying the extension folder and using the following in a view:

<?php $this->widget('ext.select2.ESelect2',array(
	'model'=>$model,
	'attribute'=>'id_city',
	'data'=>CHtml::listData(Cliente::model()->findAll(), 'id', 'nombre'),
)); ?>


Simple code to implement, works fine and looks nice.

Just wanted to share what I used as a solution.


I wouldn't do it that way whenever you have to use an autocomplete. I would make use of the source for an ajax response.

Thanks for posting your solution, in fact, TbSelect2 is a new widget ready for the next version of YiiBooster. I just hope to have some time free to do it sometime soon.

My son gets operated, so I wont be able to do it till late this weekend.

Cheers and apologies for late response to all of you.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#106 User is offline   deez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 04-January 12

Posted 20 November 2012 - 01:08 PM

View PostAntonio Ramirez, on 20 November 2012 - 02:53 AM, said:

Could you tell me what is the browser you are using? I found my self having to modify some of the jquery plugins used, maybe this is one of the cases


I am using Chrome 23.0.1271.64.

And I wish your son the best...
0

#107 User is offline   David Walker 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 21-August 12

Posted 22 November 2012 - 06:51 AM

Hi,

Wonder if anyone else has had a similar issue. I am using An TBEditableField within a CGridview (using renderpartial) which is working fine. However I also have a dropdown box and AJAX button which add an item to the Gridview and causes the Gridview to refresh. When this happens the TBeditableFields stop working until you manually reload the page using F5. I have attached screenshot of what happens.

I can see from firebug that when the Gridview refreshes the items lose the editable attributes

<a href="#" rel="Attributevalue_value_102" data-pk="102" data-placement="right" data-original-title="Enter Value" class="editable">C</a>


changes to

<a href="#" rel="Attributevalue_value_102" data-pk="102">C</a>


I have found this on Stack Overflow but I have tried adding the suggestion to now avail.

Any suggestions would be greatly received.

Thanks

David

Attached File(s)


0

#108 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 25 November 2012 - 09:54 AM

View PostDavid Walker, on 22 November 2012 - 06:51 AM, said:

Hi,

Wonder if anyone else has had a similar issue. I am using An TBEditableField within a CGridview (using renderpartial) which is working fine. However I also have a dropdown box and AJAX button which add an item to the Gridview and causes the Gridview to refresh. When this happens the TBeditableFields stop working until you manually reload the page using F5. I have attached screenshot of what happens.

I can see from firebug that when the Gridview refreshes the items lose the editable attributes

<a href="#" rel="Attributevalue_value_102" data-pk="102" data-placement="right" data-original-title="Enter Value" class="editable">C</a>


changes to

<a href="#" rel="Attributevalue_value_102" data-pk="102">C</a>


I have found this on Stack Overflow but I have tried adding the suggestion to now avail.

Any suggestions would be greatly received.

Thanks

David


Instead of using TbEditableField use TbEditableColumn that solves the issue of ajax refresh a grid :)
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#109 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 25 November 2012 - 09:56 AM

View Postdeez, on 20 November 2012 - 01:08 PM, said:

I am using Chrome 23.0.1271.64.

And I wish your son the best...



Thank you so much for your wishes... my son came out great... everything went fine...

I am sorry but it seems there is an issue with the CSS... will talk to the designer at the company trying to figure out what is the reason of such behavior. If you could provide some example code for us, would be highly appreciated.

Thanks!
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#110 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 26 November 2012 - 12:51 AM

YiiBooster 1.0.4 is out
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#111 User is offline   bit0123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 01-February 12
  • Location:Bangladesh

Posted 26 November 2012 - 02:56 AM

View PostAntonio Ramirez, on 26 November 2012 - 12:51 AM, said:

YiiBooster 1.0.4 is out


Thanks for your great effort.
How to use image gallery?
Any code snippet will be appreciated.
0

#112 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 26 November 2012 - 05:57 AM

View Postbit0123, on 26 November 2012 - 02:56 AM, said:

Thanks for your great effort.
How to use image gallery?
Any code snippet will be appreciated.


Going to write two wikis:

One for the gallery
Another one for the fileUpload

I am doing both right now
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#113 User is offline   tomsea 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 25-November 11

Posted 26 November 2012 - 10:06 AM

Thank you Antonio for a new version of YiiBooster!

Would you please specify in the YiiBooster documentation the options available for 'select2'? I mean the options that you made available in your YiiBooster implementation and that there are not documentation available elsewhere (e.g. 'asDropDownList' property), not the full set of options that we can set in the 'options' property (which we can read in the 'select2' official documentation). It would be a great plus for the documentation of YiiBooster to have something like this for every component.

Of course, only if there are new options/properties introduced by you in your YiiBooster implementation. Those are the options that I'm referring to, that I think it's a good idea to list and document in every component.
0

#114 User is offline   tomsea 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 25-November 11

Posted 26 November 2012 - 10:22 AM

Antonio, I can't get the placeholder of 'select2' to show... am I doing something wrong?

<?php $this->widget('bootstrap.widgets.TbSelect2', array(
	'model'=>$model,
	'attribute'=>'id_city',
	'asDropDownList'=>true,
	'data'=>CHtml::encodeArray(CHtml::listData(City::model()->findAll(), 'id', 'name')),
	'options' => array(
		'placeholder' => 'Please select',
		'allowClear'=>false,
))); ?>


It loads the values correctly but the first value is automatically pre-selected in the list. I want it to show 'Please select' to force the user to select an option.

I was using the 'eselect2' extension before, and this code was working for me:

<?php $this->widget('ext.select2.ESelect2',array(
	'model'=>$model,
	'attribute'=>'id_city',
	'data'=>CHtml::encodeArray(CHtml::listData(City::model()->findAll(), 'id', 'name')),
	'options'=>array(
		'placeholder'=>'Please select',
		'allowClear'=>false,
))); ?>

0

#115 User is offline   bit0123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 01-February 12
  • Location:Bangladesh

Posted 26 November 2012 - 11:18 AM

View PostAntonio Ramirez, on 26 November 2012 - 05:57 AM, said:

Going to write two wikis:

One for the gallery
Another one for the fileUpload

I am doing both right now


Thanks.
You are great.
Go ahead...
0

#116 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 26 November 2012 - 12:35 PM

View Posttomsea, on 26 November 2012 - 10:22 AM, said:

Antonio, I can't get the placeholder of 'select2' to show... am I doing something wrong?

<?php $this->widget('bootstrap.widgets.TbSelect2', array(
	'model'=>$model,
	'attribute'=>'id_city',
	'asDropDownList'=>true,
	'data'=>CHtml::encodeArray(CHtml::listData(City::model()->findAll(), 'id', 'name')),
	'options' => array(
		'placeholder' => 'Please select',
		'allowClear'=>false,
))); ?>


It loads the values correctly but the first value is automatically pre-selected in the list. I want it to show 'Please select' to force the user to select an option.

I was using the 'eselect2' extension before, and this code was working for me:

<?php $this->widget('ext.select2.ESelect2',array(
	'model'=>$model,
	'attribute'=>'id_city',
	'data'=>CHtml::encodeArray(CHtml::listData(City::model()->findAll(), 'id', 'name')),
	'options'=>array(
		'placeholder'=>'Please select',
		'allowClear'=>false,
))); ?>



No need for CHtml::encodeArray, apart from that, all seems right to me...
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#117 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 26 November 2012 - 12:36 PM

View Postbit0123, on 26 November 2012 - 11:18 AM, said:

Thanks.
You are great.
Go ahead...


Will have to wait one more day... got caught up by work
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#118 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 26 November 2012 - 01:46 PM

View Posttomsea, on 26 November 2012 - 10:06 AM, said:

Thank you Antonio for a new version of YiiBooster!

Would you please specify in the YiiBooster documentation the options available for 'select2'? I mean the options that you made available in your YiiBooster implementation and that there are not documentation available elsewhere (e.g. 'asDropDownList' property), not the full set of options that we can set in the 'options' property (which we can read in the 'select2' official documentation). It would be a great plus for the documentation of YiiBooster to have something like this for every component.

Of course, only if there are new options/properties introduced by you in your YiiBooster implementation. Those are the options that I'm referring to, that I think it's a good idea to list and document in every component.


I am planning to create a new repository at git, to work for the API Docs. I am so busy right now that is nearly impossible to do it alone and keep up with new versions.

Will let you know when it happens

Thanks
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#119 User is offline   Don Felipe 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 02-January 11
  • Location:Saigon, Vietnam

Posted 27 November 2012 - 12:07 AM

Hola Antonio,


you didn't include TbExtendedFilter in version 1.0.4. I was really looking forward to it... bummer!

An observation: Shouldn't the input for TbSelect2 have round corners, too?

Another question: Is there any way to omit the highlighting of errors in forms? It would be quite useful if there were the following boolean options: highlightErrorsOnLabels, highlightErrorsOnInputs, highlightErrorsOnHelpers. Of course the default is true. When set to false the element will not be highlighted red if there is any error.

Edit: The original option "errorMessageCssClass" gets overwritten in TbActiveForm and it would only effect the help-block (not the label and input) hence the overwrite.


Cheers,
Felipe
0

#120 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 27 November 2012 - 05:02 AM

View Postbit0123, on 26 November 2012 - 11:18 AM, said:

Thanks.
You are great.
Go ahead...


There you go for the Image Gallery, will try to write the second one asap...

http://www.yiiframew...tstrap-gallery/

Cheers
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

Share this topic:


  • (16 Pages)
  • +
  • « First
  • 4
  • 5
  • 6
  • 7
  • 8
  • Last »
  • You cannot start a new topic
  • This topic is locked

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users