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

Jump to content

  • (15 Pages)
  • +
  • « First
  • 8
  • 9
  • 10
  • 11
  • 12
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] multimodelform/jqrelcopy Solutions for clientside cloning Rate Topic: ***** 4 Votes

#181 User is offline   andjelko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-February 12

Posted 27 July 2012 - 12:57 AM

How to call value for each row in multimodelform?

it doesn’t work: $model->id

'value'=>Product::Model()->findByAttributes(array(id=>$model->id))->name)


Cheers,
Andjelko
0

#182 User is offline   IRCSASW 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 01-September 11
  • Location:Cancún, México.

Posted 31 July 2012 - 09:20 PM

Hi Joblo,

Why is it that I get two columns of "Remove" for each new element?

Attached File(s)


Arturo Ramos
www.ircsasoftware.com.mx
Cancún, México
0

#183 User is offline   Davjack 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 17-November 11

Posted 08 August 2012 - 04:02 AM

I went back to looking after multimodelform and my problem is finally this one:
Every time I create a group element with one or more members, one additional member is saved (all fields are blank) ...

I can not find what it is. This ghost member is added at the time of validation of Members:

MultiModelForm :: validate ($ member, $ validatedMembers, $ deleteMembers);


I'm lost ... :(
0

#184 User is offline   Davjack 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 17-November 11

Posted 08 August 2012 - 12:37 PM

View PostDavjack, on 08 August 2012 - 04:02 AM, said:

I went back to looking after multimodelform and my problem is finally this one:
Every time I create a group element with one or more members, one additional member is saved (all fields are blank) ...

I can not find what it is. This ghost member is added at the time of validation of Members:

MultiModelForm :: validate ($ member, $ validatedMembers, $ deleteMembers);


I'm lost ... :(

The "ghost" member is apparently due to the copyTemplate. Now I'm searching why it's saved as a member.
0

#185 User is offline   Joblo 

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

Posted 08 August 2012 - 01:57 PM

Maybe an input element of the copyTemplate is not really empty (a dropdown default value ...)
0

#186 User is offline   Davjack 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 17-November 11

Posted 09 August 2012 - 04:31 AM

View PostJoblo, on 08 August 2012 - 01:57 PM, said:

Maybe an input element of the copyTemplate is not really empty (a dropdown default value ...)

Arg... it was this (dropdown)!

Thank you Joblo
0

#187 User is offline   eestevao 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 05-July 12

Posted 17 August 2012 - 09:48 AM

Well, a diferent problem...mostly i think is JS related..

jqrelcopy worked fine, but some fields that have masked input are behaving just weird..

have 2 fields, data_emissao and data_validade, both have masks (99/99/9999).

when i execute jqrelcopy (when copy the fields)

all ok, id changed everything fine.. so i have data_emissao_0, data_validade_0 and data_emissao_1 and data_validade_1.

When i type in data_validade_1 changes the text inside both data_validade.

I don't know if i'm making myself clear (my english is not so good, as may you have noticed).

Any ideas?
0

#188 User is offline   bmac 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-January 11

Posted 03 October 2012 - 09:37 PM

View PostIRCSASW, on 31 July 2012 - 09:20 PM, said:

Hi Joblo,

Why is it that I get two columns of "Remove" for each new element?


This is happening for me also.
0

#189 User is offline   Jimlam 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 195
  • Joined: 17-March 12

Posted 04 October 2012 - 07:33 AM

View PostBraden McLeish, on 03 October 2012 - 09:37 PM, said:

This is happening for me also.


hideCopyTemplate should be set to false


	$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

			//if submitted (not empty) from the controller,
			//the form will be rendered with validation errors
			'validatedItems' => $validatedMembers,
			'tableView'=>true,
			'hideCopyTemplate' => false, //should be set to false


0

#190 User is offline   bmac 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-January 11

Posted 04 October 2012 - 11:50 AM

View PostJimlam, on 04 October 2012 - 07:33 AM, said:

hideCopyTemplate should be set to false


I appreciate the help. This helped me to remove the duplication, but it is only a minor fix as I now do not have the ability to hide the original item. Any way around that?
0

#191 User is offline   Jimlam 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 195
  • Joined: 17-March 12

Posted 12 October 2012 - 02:56 AM

View PostBraden McLeish, on 04 October 2012 - 11:50 AM, said:

I appreciate the help. This helped me to remove the duplication, but it is only a minor fix as I now do not have the ability to hide the original item. Any way around that?

Hi,

I took some time to understand the code and managed to find some workarounds to achieve some little things. I guess there must be better ways to do it.

To achieve what you want, try to modify the jquery.relcopy.yii.3.3.js(or whichever version you are using) in the following way:-

Replace this:
              funcBeforeClone.call(master);



                var parent = $(master).parent();

                var clone = $(master).clone(true).addClass(settings.copyClass+counter).append(settings.append);

                funcAfterClone.call(clone);

by this:

              funcBeforeClone.call(master);



                var parent = $(master).parent();

                var clone = $(master).clone(true).addClass(settings.copyClass+counter);//see the change here

                funcAfterClone.call(clone);


Hope it works :)

But if you do not hide the template, you will no longer have the remove link.
0

#192 User is offline   Jimlam 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 195
  • Joined: 17-March 12

Posted 12 October 2012 - 03:48 AM

Hi there to those who are interested with the autocomplete feature with this extension.

I worked around the extension code in all possible ways but could not get it to function. Finally I gave up and looked for a way to do it in my view form itself. The results are quite satisfactory except that the autocomplete feature never works on the 1st clone. I could not figure out why and had to give up here also.

Here is the javascript code that I added to my view:

<script TYPE="text/javascript" LANGUAGE="JavaScript"> 
function init(x) {
		var descrip = x.replace("item_id","descrip");
		var unitprice = x.replace("item_id","unitprice");	
		var obj = <?php echo $auto; ?>;
		$("#"+x).autocomplete("destroy").autocomplete({source:obj,minLength:3,
		select: function( event, ui ) {$("#"+descrip).val(ui.item.label);
		$("#"+unitprice).val(ui.item.prix1);}});
		this.autocomplete();
		}
 </script> 


And here is the code where the javascript gets fired (onfocus):
	$itemsorderedFormConfig = array(
		  'elements'=>array(
		  
            'item_id'=>array(              
               'type'=>'zii.widgets.jui.CJuiAutoComplete',
               'source'=>$auto,
					'options'=>array(
					 	'minLength'=>3,
					 	'showAnim'=>'fold',
					),
					'htmlOptions'=>array(

				       'size'=>4,
				       'onFocus'=>"init(this.id)",
				   ),
      		),



Hope it may be of some help to someone :D

@Joblo, thank you very much for this extension. It is invaluable!!
0

#193 User is offline   bmac 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-January 11

Posted 12 October 2012 - 09:14 AM

View PostJimlam, on 12 October 2012 - 02:56 AM, said:

Hi,

I took some time to understand the code and managed to find some workarounds to achieve some little things. I guess there must be better ways to do it.

To achieve what you want, try to modify the jquery.relcopy.yii.3.3.js(or whichever version you are using) in the following way:-

Replace this:
              funcBeforeClone.call(master);



                var parent = $(master).parent();

                var clone = $(master).clone(true).addClass(settings.copyClass+counter).append(settings.append);

                funcAfterClone.call(clone);

by this:

              funcBeforeClone.call(master);



                var parent = $(master).parent();

                var clone = $(master).clone(true).addClass(settings.copyClass+counter);//see the change here

                funcAfterClone.call(clone);


Hope it works :)

But if you do not hide the template, you will no longer have the remove link.


Thank you. I will try it out.
0

#194 User is offline   13on 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 06-October 12

Posted 27 October 2012 - 05:48 PM

Hi Joblo,
Thank for great extension.
It work, but I have a problem.
I need to use CUploadedFile with sub form.
I don't know how it get data for getInstance.
Can you write example for me?
Thank a lot.
Best wish.
0

#195 User is offline   sgonzalezmo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-June 12

Posted 30 October 2012 - 04:05 AM

Hi all

I need a help with a simple question, how to call value for each row in multimodelform? I need to link the dropdonwlist 'subactivitat_id' to the value selected in the dropdownlist 'activitat_id'. Attached the code below.

$memberFormConfig = array(
      'elements'=>array(
        'activitat_id'=>array(
            'type'=>'dropdownlist',
			'items'=>array(''=>'') + CHtml::listData(Activitats::model()->findAll(array('order'=>'descripcio ASC')), 'id_activitat', 'descripcio'),
			'onchange'=>'
                        var id = this.id;
						var indexid = id.substring(24,id.length);
						var drop = "#Imputacions_subactivitat_id"+indexid;
						var url ="'.$this->createUrl("Setmanes/dynamicSubActivitat").'";
						$.post(url, { id: $(this).val() }, function(data) {
							data = JSON.parse(data);
							$(drop).html(data.dropDownSubactivitats);
                        });',
        ),
		'subactivitat_id'=>array(
            'type'=>'dropdownlist',
			'items'=>array(''=>'') + CHtml::listData(Subactivitats::model()->findAll(array('order'=>'descripcio ASC', 'condition'=>'activitat_id=:activitat_id', 'params'=>array(':activitat_id'=>(int) $validatedMembers['1']->activitat_id))), 'id_subactivitat', 'descripcio'),
        ),


Thks for your help.
0

#196 User is offline   ragua 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 135
  • Joined: 23-January 12
  • Location:Paris - France

Posted 05 November 2012 - 06:20 AM

Hi,
to Sgonzalesmo an example of dependant dropdown in multimodelform. In my use, there is only one occurence, so you'll have to modify some more.

The "name" of the field is different if your occurrence is created or updated, so i use a variable ($update) in my form
$update = '#'.CHtml::activeId($relStudentSemester,'level');
foreach ($relStudentSemester_w as $models)
{
   ...
   $update = "#RelStudentSemester_u___0_level";
}

   ...

$relStudentSemesterFormConfig = array(
   'elements'=>array(
      ...
      'test_result'=>array(
          'type'=>'text',
          'maxlength'=>3,
          'size'=>3,
          'ajax'=>array(
       	      'type'=>'POST',
		'dataType'=>'json', 
		'data'=>array('test_result'=>'js:this.value'), 
                'url'=>CController::createUrl('student/testResult'),
		'success'=>'function(data) {
		     $("'.$update.'").html(data.dropDownA);
		}',
            ), 
        ),
      ...


In the controller, actionTestResult:
        ...
	if($retour)
	{
		$dropDownA = CHtml::tag('option', array('value'=>$level),CHtml::encode($level),true);
	}
	else 
	{
		$dropDownA = CHtml::tag('option', array('value'=>''),CHtml::encode('-'),true);
		$dropDownA .= CHtml::tag('option', array('value'=>'A1'),CHtml::encode('A1'),true);
		$dropDownA .= CHtml::tag('option', array('value'=>'A2'),CHtml::encode('A2'),true);
		$dropDownA .= CHtml::tag('option', array('value'=>'B1'),CHtml::encode('B1'),true);
		$dropDownA .= CHtml::tag('option', array('value'=>'B2C'),CHtml::encode('B2C'),true);
	}		

	echo CJSON::encode(array(
	  'dropDownA'=>$dropDownA,
	));


Hope it will help.
0

#197 User is offline   codefundi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-July 12

Posted 05 November 2012 - 11:57 PM

View Postdinhtrung, on 29 June 2011 - 01:23 AM, said:

Below is an example using Multimodelform to handle Upload files.

I create a new AR model to store files, and use Multimodel Form to handle the form.



I've set up this example on my localhost.

However, I get an error that WebBaseController.php is missing. Anyone that has successfully setup this example? What does the missing component do? Any chance you could upload it?

Thanks!
0

#198 User is offline   shoemaker 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 29-December 11

Posted 10 November 2012 - 05:16 PM

Hi,

I managed to fix the two remove columns issue, by changing multimodelform php code instead of changing relcopy code:

In function getClientOptions() on line 749 I changed
if (!empty($this->removeText))
to
 if (!empty($this->removeText) && !$this->hideCopyTemplate)


If the developer is reading this he might put it in the next version if it does not make problems elsewhere...

Regards!
Database tools for Joomla - Tools JX
1

#199 User is offline   Joblo 

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

Posted 12 November 2012 - 02:51 AM

Many thanks - fixed and published in v. 4.0
0

#200 User is offline   adoming3 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 31-July 12

Posted 20 November 2012 - 12:04 AM

I am having problems with CJuiDatePicker. Unless the date attribute is required in my model than the date column does not appear in the view. However, I would like the date attribute to NOT be required. Does anyone have any suggestions? Thanks in advance.

Please see my _form.

	<div class="hidden">
		<?php $form->widget('zii.widgets.jui.CJuiDatePicker', array(
		             'model'=>$lease,
		             'attribute'=>'lxp',
		             'name'=>'lxp',
		             'options'=>array(
		               'showAnim'=>'fold')),true); ?>
		<?php echo $form->error($lease,'lxp'); ?>
	</div>

	<?php

	$leaseFormConfig = array(
	      'elements'=>array(
	        'lxp'=>array(              
                'type'=>'zii.widgets.jui.CJuiDatePicker',
                'language'=>'en',
                'options'=>array(
                    'showAnim'=>'show',
                    'changeYear'=>'true',
                    'yearRange'=>'-nn:c+50',
                    ),
                'htmlOptions'=>array(
                  'class'=>'input-medium',
                  ),
	        ),
	    ));

	$this->widget('ext.multimodelform.MultiModelForm',array(
	      'id'=>'id_lease', //the unique widget id
	      'formConfig'=>$leaseFormConfig, //the form configuration array
	      'model'=>$lease, //instance of the form model
	      //if submitted not empty from the controller,
	      //the form will be rendered with validation errors
	      'validatedItems'=>$validatedLeases,
	      
	      'addItemText'=>'<br><button type="button" class="btn-info">Add Tenant</button><br><br>',
	      
	      'removeText'=>'<button type="button" class="btn-danger">Remove</button>',	      
	      
	      //array of lease instances loaded from db
	      'data'=>$lease->findAll('property_id=:property_id',array(':property_id'=>$property->id)),
	      
	      //display as a horizontal table
	      'tableView'=>true,
	      
	      //prevent extra remove from tableView
	      'hideCopyTemplate'=>false,	      
	      
	      'jsAfterNewId'=>MultiModelForm::afterNewIdDatePicker($leaseFormConfig['elements']
	      ['lxp']), 	      
	    ));
     

0

Share this topic:


  • (15 Pages)
  • +
  • « First
  • 8
  • 9
  • 10
  • 11
  • 12
  • Last »
  • 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