Yii Framework Forum: [EXTENSION] multimodelform/jqrelcopy - Yii Framework Forum

Jump to content

  • (15 Pages)
  • +
  • « First
  • 13
  • 14
  • 15
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] multimodelform/jqrelcopy Solutions for clientside cloning

#281 User is offline   Joblo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 703
  • Joined: 12-September 10
  • Location:Austria

Posted 24 September 2014 - 01:46 AM

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.
0

#282 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 94
  • Joined: 10-February 12

Posted 24 September 2014 - 02:20 AM

View PostJoblo, on 24 September 2014 - 01:46 AM, said:

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.
0

#283 User is offline   Joblo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 703
  • Joined: 12-September 10
  • Location:Austria

Posted 24 September 2014 - 02:22 AM

Sorry: set 'pk__' instead of 'pk_'
0

#284 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 94
  • Joined: 10-February 12

Posted 24 September 2014 - 02:23 AM

View PostJoblo, on 24 September 2014 - 02:22 AM, said:

Sorry: set 'pk__' instead of 'pk_'

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

#285 User is offline   Joblo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 703
  • Joined: 12-September 10
  • Location:Austria

Posted 24 September 2014 - 02:27 AM

Updated on github
0

#286 User is offline   phdCoder 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 02-October 13

Posted 18 October 2014 - 06:37 AM

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 ?
0

#287 User is offline   Joblo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 703
  • Joined: 12-September 10
  • Location:Austria

Posted 19 October 2014 - 09:14 AM

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
0

#288 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 27 November 2014 - 11:26 AM

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); }'
							        ), 
							    ),
							 	
						  	), 
...


Attached File  Screen Shot 2014-11-27 at 19.14.07.png (155.44K)
Number of downloads: 14

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.
0

#289 User is offline   bhushanlambat 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 24-September 14

Posted 28 November 2014 - 01:38 AM

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.......
0

#290 User is offline   devility 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 01-October 14

Posted 16 December 2014 - 04:05 PM

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!
0

#291 User is offline   Roy Argaez 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 29-May 14
  • Location:Cancún, Quintana Roo, México.

Posted 26 January 2015 - 05:38 PM

Hi Forum,

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

Sorry for my English, beforehand Thanks
IRCSA Software.
Roy Argaez
0

#292 User is offline   Dhara 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 26-April 14
  • Location:Ahmedabad, India

Posted 09 March 2015 - 06:55 AM

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?
0

#293 User is offline   Dhara 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 26-April 14
  • Location:Ahmedabad, India

Posted 13 March 2015 - 12:40 AM

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.
0

#294 User is offline   Joblo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 703
  • Joined: 12-September 10
  • Location:Austria

Posted 13 March 2015 - 03:12 AM

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.
0

#295 User is offline   Dhara 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 26-April 14
  • Location:Ahmedabad, India

Posted 13 March 2015 - 06:59 AM

View PostJoblo, on 13 March 2015 - 03:12 AM, said:

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.
0

#296 User is offline   franjalafa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 17-September 13
  • Location:México

Posted 18 March 2015 - 08:03 PM

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
0

#297 User is offline   Depe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-May 15

Posted 18 May 2015 - 06:01 AM

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
0

#298 User is offline   SCare 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-May 15

Posted 26 May 2015 - 04:15 AM

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.
0

#299 User is offline   Seventrust 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 28-July 15

Posted 28 July 2015 - 09:57 AM

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)),
        ));

0

#300 User is offline   Roy Argaez 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 29-May 14
  • Location:Cancún, Quintana Roo, México.

Posted 14 October 2015 - 05:46 PM

Quote

Hello forum.

I want to know how I can setting the focus to a field when adding a new item ?
I apologize for my English.

Awaiting your reply , thanks.

IRCSA Software.
Roy Argaez
0

Share this topic:


  • (15 Pages)
  • +
  • « First
  • 13
  • 14
  • 15
  • You cannot start a new topic
  • You cannot reply to this topic

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