[EXTENSION] multimodelform/jqrelcopy Solutions for clientside cloning
#181
Posted 27 July 2012 - 12:57 AM
it doesn’t work: $model->id
'value'=>Product::Model()->findByAttributes(array(id=>$model->id))->name)
Cheers,
Andjelko
#182
Posted 31 July 2012 - 09:20 PM
Why is it that I get two columns of "Remove" for each new element?
Attached File(s)
-
multimodel_remove.png (8.55K)
Number of downloads: 34
#183
Posted 08 August 2012 - 04:02 AM
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 ...
#184
Posted 08 August 2012 - 12:37 PM
Davjack, on 08 August 2012 - 04:02 AM, said:
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.
#185
Posted 08 August 2012 - 01:57 PM
#187
Posted 17 August 2012 - 09:48 AM
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?
#189
Posted 04 October 2012 - 07:33 AM
Braden McLeish, on 03 October 2012 - 09:37 PM, said:
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
#191
Posted 12 October 2012 - 02:56 AM
Braden McLeish, on 04 October 2012 - 11:50 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.
#192
Posted 12 October 2012 - 03:48 AM
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
@Joblo, thank you very much for this extension. It is invaluable!!
#193
Posted 12 October 2012 - 09:14 AM
Jimlam, on 12 October 2012 - 02:56 AM, said:
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.
#194
Posted 27 October 2012 - 05:48 PM
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.
#195
Posted 30 October 2012 - 04:05 AM
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.
#196
Posted 05 November 2012 - 06:20 AM
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.
#197
Posted 05 November 2012 - 11:57 PM
dinhtrung, on 29 June 2011 - 01:23 AM, said:
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!
#198
Posted 10 November 2012 - 05:16 PM
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!
#200
Posted 20 November 2012 - 12:04 AM
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']),
));

Help













