Yiibooster

As Antonio said why is what’s available not good enough? In TbActiveForm you can use datepickerRow(). It will render a date picker with the familiar bootstrap look & feel and imho it’s even more user-friendly when one tries to select a different year and month for instance.

If there’s something missing for datepickerRow() or could be done better, you should elaborate this?

Thumbs up on Notify!

Well… here’s the story:

  1. I want the altField/altFormat functionality of JuiDatePicker.

  2. It’s not an option to do formatting stuff in beforeSave/afterFind, because I think dates must always be canonical and from the source. altField/altFormat fits the requirement of showing the date in a user friendly way and also POSTing the date in canonical (YYYY-MM-DD).

  3. Tried to add that functionality to bootstrap.datepicker, but my JS skills are very poor.

  4. JuiDatePicker already have the functionality and I already developed a wrapper to implement altField/altFormat in Yii (it’s different from Yii implementation. The widget autocreate the hidden field and set that as the field to be posted. To me, this sounded more practical).

That’s why I found myself trying to implement the wrapper in TbActiveForm. First, because I find YiiBooster very good and is my choice for developing UI. Second, because I feel there’s an opportunity on discuss and propose improvements. And third, because I cannot understand why widgets like JuiDatpicker (which are obvious field widgets) has to be treated different from other field widgets (or maybe I wasn’t smart enough to found it).

Cheers and keep up the good work!

Hey @Antonio.

There two things I want to know.

  1. Is there a way to have more than on TbEditableColumn in Grid View? How would be a controller action to handle this?

  2. I can’t get to work the component with Csrf;

‘request’=>array(

'enableCsrfValidation'=>true,

Yes you can… and for the CSRF, you will need to add to the update url for the TbEditableColumn setting

Hi!

Thanks for the wonderful extension. I am new to Yii and am trying to get the inline edit extension(TbJEditableColumn) working.

ATM, i can double click on a field, it becomes editable, but when I hit enter to save it. It saves with the whole page content inside the field plus the new data I added. I have included some screen shots to explain what I mean.

So my question is how do I get just the updated text to render in the field?

Here is my code, all from admin.php.




<?php $this->widget('bootstrap.widgets.TbExtendedGridView', array(

    'type'=>'striped bordered',

	'dataProvider'=>$model->search(),

    'template' => "{items}",

	'filter'=>$model,

	'columns'=>array(

            array('name'=>'id'),

            array('name'=>'image_name'),

            array(

                'name'=>'image_description',

                'class'=>'bootstrap.widgets.TbJEditableColumn',

                'jEditableOptions'=>array(

                    'type'=>'text',

                    'submitdata'=>array('attribute'=>'image_description'),

                    'cssclass'=>'form',

                    'width'=>'180px'

                )

            ),

            array('name'=>'image_caption'),

            array('name'=>'date_taken'),

            array('name'=>'location'),

            /*

            'metadata',

            */

            array(

                'class'=>'CButtonColumn',

            ),

        )

)); ?>


<?php

$r = Yii::app()->getRequest();

// we can check whether is comming from a specific grid id too

// avoided for the sake of the example

if($r->getParam('editable'))

{

    //echo $r->getParam('attribute');

    echo $r->getParam('value');

    Yii::app()->end();

}

?>



As you can see I am not at the next step of saving the model back to the database, (as a side note, I am not sure how to do that either yet).

I want to use Navigation Tabs dynamically i.e. the content will come from database. How to achieve that?

For example, say I’ve two database tables, named as category and sub-category. When I will click on one category, its sub-category would display using ajax calls. To make it fast and use-friendly, I want to use vertical navigation tabs. Please help.

The issue is the echoed data at the server… you are actually rendering the whole page again… what you need to return is the actual value that needs to be re-rendered on the edited field column.

If you still have issues, I highly recommend you to use TbEditableColumn is much better and comes an already to use widget for updating automatically the column value.

Whats the question for YiIBooster? You want to create Tabs dynamically on the frontend scripts or at the PHP script level. Please, elaborate your question a bit more

How to use TbSelect2 wideget?

I am trying to use in the following way:


echo $form->select2Row($model,'container_id','data' => CHtml::listData(Container::model()->findAll(),'id', 'number'));

I have also tried:


echo $form->select2Row($model,'container_id',CHtml::listData(Container::model()->findAll(),'id', 'number'));

But no success.

Thanks in advance…

Hi!

I’ve been using Booster release from 25th of November. Just tried to update it to latest official version & latest github version. With both of these new versions, my modals are not working at all. No javascript errors, they just don’t appear (but cause some strange ajax updating). Will try to figure out what’s going on there, but would be great if you could point me to right direction ie. has the modal functionality been changed lately (couldn’t find any mentioning in Github)? Also pull-right doesn’t seem to work with the latest.

Thanks,

Timo

Thanks for your reply Antonio,

As per your suggestion I took a look at TbEditableColumn and have made some more progress.

I do have a question about it though.

On the components.html#editable page it has this example




$this->widget('bootstrap.widgets.TbGridView', array(

	'type' => 'striped bordered',

	'dataProvider' => new CActiveDataProvider('Region',array(

		'criteria'=>array('condition'=>'id < 5'))

	),

	'template' => "{items}",

	'columns' => array(

		'country_code',

		array(

			'class' => 'bootstrap.widgets.TbEditableColumn',

			'name' => 'name',

			'sortable'=>false,

			'editable' => array(

				'url' => $this->createUrl('site/editable'),

				'placement' => 'right',

				'inputclass' => 'span3'

			)

		)),

));



So am I supposed to create a method called editable inside my controller?

So change this line


'url' => $this->createUrl('site/editable'),

to


'url' => $this->createUrl('image/editable'),

or can I use my actionUpdate method inside my image controller like this?


'url' => $this->createUrl('image/update'),

ATM I have it set up to statically update image with id equal to 1 like this:


'url' => $this->createUrl('image/update', array('id'=>'1')),

This updates the frontend but is not retained when the page is refreshed.

Is there anything else I need to do?

Regards,

You are almost there!

The third parameter needs to be an array containing data as sub-array. Try this:


echo $form->select2Row(

    $model,

    'container_id',

    array(

        'data' => CHtml::listData(Container::model()->findAll(), 'id', 'number'),

        //'options' => array( ... ),

    )

);

It Works.

Thank you…

In YIIBooster, tabs content are static. I want to make it dynamic (content from database). Whenever the tabs are clicked, the content will be fetched from database. How do I achieve that?

Problem with Form in Modal(TbModal)

I have rendered a form in the Modal body using renderpartial.

The form is for creating new ‘product’ object.

But the validation is not working also the default ‘create’ button in

the form does not working.

Please help.

Thanks in advance.

Please post your view file/s and controller actions and any error messages (firebug/php) if any.

Thanks for your intention.

This is the view file where i have render another view in Moodal body




...

...

...

<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'myModal')); ?>

 

    <div class="modal-header">

        <a class="close" data-dismiss="modal">x</a>

    <h4>Add New Product:</h4>

    </div>

 

<div class="modal-body">

    <?php echo $this->renderPartial('//containerproduct/form', array('model'=>new Containerproduct,'c_id'=>$model->id)); ?>

</div>

 

<div class="modal-footer">

	<?php $this->widget('bootstrap.widgets.TbButton', array(

		'label'=>'Cancel',

		'url'=>'#',

		'htmlOptions'=>array('data-dismiss'=>'modal'),

	)); ?>

</div>

<?php $this->endWidget(); ?>

	<?php $this->widget('bootstrap.widgets.TbButton', array(

	'label'=>'Add Product to this Container',

	'type'=>'primary',

	'htmlOptions'=>array(

		'data-toggle'=>'modal',

		'data-target'=>'#myModal',

	),

)); ?>




The view file which i have rendered:





<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(

	'id'=>'containerproduct-form',

	'type'=>'horizontal',

	'enableAjaxValidation'=>true,

	'clientOptions'=>array(

			'validateOnSubmit'=>true,

		),

)); ?>


	<p class="help-block">Fields with <span class="required">*</span> are required.</p>

		

	

	<?php echo $c_id;echo $form->errorSummary($model); ?>

	 

	<?php echo $form->hiddenField($model,'container_id',array('value'=>$c_id)); ?>

	

	<div class='well'>

	<?php echo $form->select2Row($model,'product_id',array('data'=>CHtml::listData(Product::model()->findAll(),'id','name'), 'options' => array('width'=>'33%'))); ?>

		

	<?php echo $form->textFieldRow($model,'number',array('class'=>'span5','maxlength'=>10)); ?>


	<?php echo $form->textFieldRow($model,'waste',array('class'=>'span5','maxlength'=>10, 'default'=>0)); ?>


	<?php //echo $form->textFieldRow($model,'net',array('class'=>'span5','maxlength'=>10)); ?>


	<div class="form-actions">

		<?php $this->widget('bootstrap.widgets.TbButton', array(

			'buttonType'=>'submit',

			'type'=>'primary',

			'label'=>$model->isNewRecord ? 'Create' : 'Save',

		)); ?>

	</div>

	</div>

<?php $this->endWidget(); ?>




And In the Controller i have not done any change.

Snap is added also…

If you’re not telling the action to validate the form data… it won’t!

To keep things simple, use the same action as for the main view/page and add the following accordingly:


public function actionIndex() //replace with your action name

{

  $containerproduct = new Containerproduct;

	 	

  // if it is ajax validation request

  if(isset($_POST['ajax']) && $_POST['ajax']=='containerproduct-form')

  {

    echo CActiveForm::validate($containerproduct);

    Yii::app()->end(); //important here!!!

  }


  //rest of action code... 


  //add $containerproduct to render()...

}



Then, change the first param of renderPartial() in your main view to:


'model'=>$containerproduct

This will do the trick and validation plus button should work now.

Of course, data is only validated but not yet saved.

@Don Felipe Thanks for your reply.

I have solved the problem through defining the form action.