[EXTENSION] multimodelform/jqrelcopy

This is a bug, but I don’t know why I (and others) didn’t had this issue.

Change the method "allSubmittedAttributesEmpty" like below




protected function allSubmittedAttributesEmpty($model,$formData,$registeredForUpload)

    {

        $allEmpty = true;

        $submittedAttributes = array_keys($formData[get_class($model)]);

        foreach ($submittedAttributes as $attribute)

        {

            if(empty($attribute) || $attribute=='n__' || $attribute=='u__' || $attribute=='pk_') //bugfix 2014-09-24

                continue;

            

            if (in_array($attribute, $registeredForUpload) || !$this->isEmptyValue($model->{$attribute}))

            {

                $allEmpty = false;

                break;

            }

        }

        return $allEmpty;

    }




I will update the code on github if it works for you after this change.

Please give me a feedback.

i already change sir, but same result.

Sorry: set ‘pk__’ instead of ‘pk_’

BOOM!! thank you sir !!!!! :rolleyes:

Updated on github

Hi !!! Thanks for the great extension.

I am planning on moving to yii 2.0 . But without the functionality of your extension, i can’t!!! I am using it on almost every CRUD !!! Are you planning a yii 2.0 release ?

mmf will be one the first of all my published extensions I plan to port to yii2, because I use it in all my projects too.

But sorry, no chance at the moment.

See my comment on the github repository

I try implement Imperavi Redactor Widget for textareas with MMF, so in all textareas saved text of the first textarea. And all Imperavi tool panels work only for the first textarea.


$memberFormConfig = array(

						  'elements'=>array(


								'track_number'=>array(

									'type'=>'text',

									'maxlength'=>5,

									'class'=>'span1',

								),


						  	'title'=>array(

						  		'type'=>'text',

						  		'maxlength'=>40,

						  	),

								

						  	'text_en'=>array(

						  		'type'=>'ImperaviRedactorWidget',

									'name'=>'text_en',

									//'attribute' => 'text_en',

							    'options' => array(

							        'lang' => 'ru',

									'linebreaks' => true,

									'formattingTags'=>array('p', 'span', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4'),

									//'paragraphy' => false, 

									'buttons'=>array(

					                    'html', '|', 'formatting', '|', 'underline', 'bold', 'italic', 'deleted', '|',

										'unorderedlist', 'orderedlist', 'outdent', 'indent', '|',

										'image', 'video', 'file', 'table', 'link', '|', 'alignment', '|', 'horizontalrule',


										/*'alignleft', 'aligncenter', 'alignright', 'justify',*/

					                ),

									'minHeight' => 200, // pixels

							        //'toolbar' => false,

							        //'iframe' => true,

							        //'css' => 'wym.css',

									'fileUpload'=>Yii::app()->createUrl('group/fileUpload',array(

							            'attr'=>'contacts'

							        )),

							        'fileUploadErrorCallback'=>new CJavaScriptExpression(

							            'function(obj,json) { alert(json.error); }'

							        ),

							        'imageUpload'=>Yii::app()->createUrl('group/imageUpload',array(

							            'attr'=>'contacts'

							        )),

							        'imageGetJson'=>Yii::app()->createUrl('group/imageList',array(

							            'attr'=>'contacts'

							        )),

							        'imageUploadErrorCallback'=>new CJavaScriptExpression(

							            'function(obj,json) { alert(json.error); }'

							        ), 

							    ),

							 	

						  	), 

...

6132

Screen Shot 2014-11-27 at 19.14.07.png

new cloned textareas with Imperavi Redactor has different id: id="Song_text_en"; id="Song_text_en2"; id="Song_text_en3"; …

but how can I use them? Now MMF thinks all textareas are the same.

Hi Joblo,

I am new in Yii… Can you please suggest me how to use dependent drop-down using multimodelform extension.

I need if I select Prod_Category_Name in drop down then i ll get dependent value in Product_Name.

In form.php –

$memberFormConfig = array(

      'elements'=>array(


        'Prod_Category_Name'=>array(


           'type'=>'dropdownlist',


           'items'=>array(

CHtml::listData(productmaster::model()->findAll(), ‘Prod_Category_Name’,‘Prod_Category_Name’ ),

				 array (


				  'ajax'=>array


				  (


				 


				  'type'=> 'POST',


				  'url'=>CController::createUrl('Groupmr/selectpro'),


				  'update'=>'#'.CHtml::activeId($model,'Product_Name'),


				       ),))


                                      ),

In Controller —

public function actionSelectpro()

{


  $Prod_Cat_ID = $_POST['Groupmr']['Prod_Category_Name'];


  $lista = ProductMaster::model()->findAll('Prod_Category_Name = :id_cate', array(':id_cate'=>$Prod_Cat_ID));


  $lista = CHtml::listData($lista,'Product_Name','Product_Name');


  





  foreach ($lista as $valor=>$Product_Name)


  {


    echo CHtml::tag('option',array('value'=>$valor),CHtml::encode($Product_Name),true);


  


  


  }





}

Please guide me how to apply dependent dropdown list in our extension.

Thnx… waiting for your reply…

Hello All,

i want to use the jqrel with the CJuiAutoComplete. But when I clone the fields then the CJuiAutoComplete is not working, it is not showing the matches from the DB.

Could anyone please help to me?

Here is my source:




$this->widget('ext.jqrelcopy.JQRelcopy',

                 array(

                       'id' => 'copylink',

                       

                       ));


$datePickerConfig2 = array('name'=>'routeSearch',

	            'value'=>'',

	            'source'=>$this->createUrl('intervm/routeSearch'),

	            // additional javascript options for the autocomplete plugin

	            'options'=>array(

	                            'minLength'=>'2',

	                            'showAnim'=>'fold',

	                            'autoFill'=>true,

	            ));

 

  

   

   $this->widget('ext.jqrelcopy.JQRelcopy',

array(

      'id' => 'copylink',

      'removeText' => 'Törlés',

      //'jsBeforeNewId' => "alert(this.attr('id'));",

 

      //add the datapicker functionality to the cloned datepicker with the same options

      'jsAfterNewId' => JQRelcopy::afterNewIdAutoComplete($datePickerConfig2),

      ));


<div class="row copy">

    	


	    <div>Route:

	    		 <?php

	        $this->widget('zii.widgets.jui.CJuiAutoComplete', array(

	            'name'=>'routeSearch[]',

	            'value'=>'',

	            'source'=>$this->createUrl('mymodule/routeSearch'),

	            // additional javascript options for the autocomplete plugin

	            'options'=>array(

	                            'minLength'=>'2',

	                            'showAnim'=>'fold',

	                            'autoFill'=>true,

	            ),

	            'htmlOptions'=>array(

	                    'style'=>'height:20px;',

	                ),

	        ));    

	        ?>

	    </div>

    	</div>




Thank you!

Hi Forum,

How I can fix the header? i need after to do scrolldown the header fixed-

Sorry for my English, beforehand Thanks

It validates only first record.i fill up first record and click on add new link. Now when i click on submit button even if second record is not filled, it save record. it doesn’t validate second record.

Is there any solution?

Hello,

I have used multimodelform extension.I have followed all the steps which are written in document.

it works fine. but i have faced issue in validation. it validate only first record on click of submit. when i add second fields onclick of add new button and if i doesn’t add any values in it then it doesn’t validated. successfully inserted record which is wrong. it must be validate second record if it doesn’t filled.

My controller code




public function actionCreate()

    {

 Yii::import('ext.multimodelform.MultiModelForm');

 $validatedMembers = array();


$model=new Quote;

$model_quote_detail=new QuoteDetail;

if(isset($_POST['Quote']))

{

    $model->attributes=$_POST['Quote'];

     if(isset($_POST['Quote']))

     {

         if( MultiModelForm::validate($model_quote_detail,$validatedMembers,$deleteItems)  &&

                $model->save())

                   {

                          // save others

                  }

}

}

$this->render('create',array(

			'model'=>$model,'validatedMembers'=>$validatedMembers,'model_quote_detail'=>$model_quote_detail,

		));

}






In _form




$memberFormConfig = array(

              'elements'=>array(

                'description'=>array(

                    'type'=>'zii.widgets.jui.CJuiAutoComplete',

                    'source'=>$this->createUrl('/Quote/ProductAutocomplete'),  

                    'htmlOptions'=>array('placeholder'=>'Product','class'=>'form-control cost'),

                    'options'=>array(

                        'showAnim'=>'fold',

                        'select' =>'js: function(event, ui) {

                              var test=(this.id).substring(23, 24); 

                              var costId = "QuoteDetail_cost"+test;

                               $("#"+costId).val(ui.item.cost);

                              this.value = ui.item.value;

                              return false;

                          }',

                    ),

                ),

                'cost'=>array(

                    'type'=>'text',

                    'maxlength'=>40,

                    'placeholder'=>'Cost',

                    'class'=>'form-control cost',

                ),

            ));


$this->widget('ext.multimodelform.MultiModelForm',array(

            'id' => 'id_member', //the unique widget id

            'formConfig' => $memberFormConfig, //the form configuration array

            'model' => $model_quote_detail, //instance of the form model

            'hideCopyTemplate' => false, 

            'tableView' => false,


            'rowWrapper' => array('tag' => 'div', 'htmlOptions' => array('class' => 'col-md-5')),

            'removeLinkWrapper' => array('tag' => 'div', 'htmlOptions' => array('class' => 'form-group col-xs-12 text-right')),


            'validatedItems' => $validatedMembers,

            'jsAfterNewId'=>MultiModelForm::afterNewIdAutoComplete($memberFormConfig['elements']['description']),  


        ));



Any solution??

Thanks in advance.

See the method: allSubmittedAttributesEmpty in the code. This is called on validation.

All element values of a row will be checked.

If they are ‘empty’.

If all values are empty the row will be ignored on validation and the record will not be inserted into the db.

Thanks Joblo. I understand now.BUT if in new added record one field is filled and other is not filled. it must give error for empty field. but it doesn’t give any error.

good day, thanks for the extension , everything works fine, I need is that when you delete a row, use the removeOnClick and function call made ​​in javascript

Excuse my English , is google translate

Hi everyone,

I was wondering, can the FormConfig be used to show data from another table using relations (like in CGridView)?

Because I need to show data in every row, along with the Form.

Thank you in advance

I am using two dropdownlist in FormConfig in which one dropdownlist depends on another. But when i make a copy of it, the dependent dropdownlist shows the same values for all copies irespective of what value is selected in the first dropdownlist for that copy.

i.e. suppose i select city in first dropdownlist, the second dropdownlist shows its respective values but when i make a copy of it the second dropdown shows the same values(city values) irrespective of what is selected in the first dropdownlist.

Greering,

Joblo i have a question, how can i put some autocomplete select function when the extension mmf create a new element id, i have this code for the autocomplete field:


'Descripcion'=>array(

                'type'=>'zii.widgets.jui.CJuiAutoComplete',                

                'source'=>$this->createUrl('venta/autocomplete'),

                

                'options'=>array(

                    'showAnim'=>'fold',

                         'size'=>'120',

                         'minLength'=>'2', // Minimo de caracteres que hay que digitar antes de relizar la busqueda

                         'select'=>"js:function(event, ui) {    

                          $('#Detalleventa_CodProducto').val(ui.item.id); // HTML-Id del campo

                          $('#Detalleventa_Precio').val(ui.item.precio); //HTML-Id del campo

                            

                           }"                       

                ),

                'htmlOptions'=> array(

                        'size'=>120,

                        'placeholder'=>'Buscar ...',

                        'title'=>'Indique el producto.'

                ),

What i want to do is, take the new ID Detalleventa_CodProdcuto and Detalleventa_Precio, to autcomplete fields in the select option…

The widget options are:




$this->widget('ext.multimodelform.MultiModelForm',array(

            'id' => 'id_member', //the unique widget id

            'formConfig' => $memberFormConfig, //the form configuration array

            'model' => $member, //instance of the form model

            'tableView'=>true,

            //if submitted not empty from the controller,

            //the form will be rendered with validation errors

            'validatedItems' => $validatedMembers,

            'jsAfterNewId' => MultiModelForm::afterNewIdAutoComplete($memberFormConfig['elements']['Descripcion']),

            'addItemText' => 'Agregar',

            'removeText' => 'Quitar',

            'removeConfirm' => 'Desea quitar la fila seleccionada',

            //array of member instances loaded from db

            'data' => $member->findAll('NumVenta=:groupId', array(':groupId'=>$model->NumVenta)),

        ));