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

Jump to content

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

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

#241 User is offline   vbeiws 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 13-November 12
  • Location:India

Posted 02 April 2013 - 02:32 PM

View PostJoblo, on 02 April 2013 - 02:29 PM, said:

Sorry ... I mean a full yii app.
I can't debug this, because I have no models Order, OrderLine ...

But seems that multimodelform can't work with ajax, because of the clientside js-code on cloning.


No problem, thanks joblo, I will try something. Thanks for nice extension and your time for supporting the extension.
0

#242 User is offline   vbeiws 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 13-November 12
  • Location:India

Posted 02 April 2013 - 02:34 PM

Can you suggest any alternative extension that i can use to support my scenario??
0

#243 User is offline   Joblo 

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

Posted 02 April 2013 - 03:13 PM

Hmm... sorry I have never tested or used multimodelform with ajax.
You have to debug the js-code or take a look at the console output.
Maybe you have to work with the js-afterClone codes ... etc.

Samdark published another solution (without clientside cloning lik multimodelform) in his book 'Yii 1.1 Application Development Cookbook' (Chapter 3 Handling variable number of inputs). But this uses ajax to add records in the db and adding the form element. I'm not sure if your 'ajax in ajax' work with this implementation.
0

#244 User is offline   vbeiws 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 13-November 12
  • Location:India

Posted 03 April 2013 - 09:26 AM

View PostJoblo, on 02 April 2013 - 03:13 PM, said:

Hmm... sorry I have never tested or used multimodelform with ajax.
You have to debug the js-code or take a look at the console output.
Maybe you have to work with the js-afterClone codes ... etc.

Samdark published another solution (without clientside cloning lik multimodelform) in his book 'Yii 1.1 Application Development Cookbook' (Chapter 3 Handling variable number of inputs). But this uses ajax to add records in the db and adding the form element. I'm not sure if your 'ajax in ajax' work with this implementation.

@ JOblo,

Good news, with some digging inside your Js file and a bit of hard coding of some type, I was able to achieve the dependent scenarios and hell, any thing even if it is a dependent dropdown type scenario or db calls or client side javascript etc.
I am not sure if this can be implemented inside your main extension. let me know if you have time and can have a look at my code. If integrating this to main extension is possible, it will be great for lots of users.

"NOT TO MENTION, THANKS AGAIN FOR SUCH A DIVINE EXTENSION. Many thanks."
0

#245 User is offline   Joblo 

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

Posted 03 April 2013 - 11:39 AM

Can you publish the modified js-file with a description, what problems it solves?

An easy step what I can do, is to add a public property 'jsFile' to allow to use customized js-files in the next release.
So every one can copy the default file, make the changes he needs and switch to the customized js-file without touching the basic core.
0

#246 User is offline   bmac 

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

Posted 30 May 2013 - 03:55 PM

Is there an option to require the user to input at least 1 record?
0

#247 User is offline   Joblo 

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

Posted 31 May 2013 - 03:52 AM

In your controller you have to split validate and save of the MultiModelForm as mentioned in the online docu.

//validate formdata and populate $validatedItems/$deleteItems
if (MultiModelForm::validate($model,$validatedItems,$deleteItems,$masterValues)) 
{
 
 if(empty($validatedItems)
 {
    //submit a message to the form (userflash ....)

 } 
 else
   MultiModelForm::save($model,$validatedItems,$deleteItems,$masterValues);
}


0

#248 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 485
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 04 June 2013 - 11:02 AM

View Postvbeiws, on 03 April 2013 - 09:26 AM, said:

@ JOblo,

Good news, with some digging inside your Js file and a bit of hard coding of some type, I was able to achieve the dependent scenarios and hell, any thing even if it is a dependent dropdown type scenario or db calls or client side javascript etc.
I am not sure if this can be implemented inside your main extension. let me know if you have time and can have a look at my code. If integrating this to main extension is possible, it will be great for lots of users.

"NOT TO MENTION, THANKS AGAIN FOR SUCH A DIVINE EXTENSION. Many thanks."



View PostJoblo, on 03 April 2013 - 11:39 AM, said:

Can you publish the modified js-file with a description, what problems it solves?

An easy step what I can do, is to add a public property 'jsFile' to allow to use customized js-files in the next release.
So every one can copy the default file, make the changes he needs and switch to the customized js-file without touching the basic core.


Yes please, publish the code as it sounds like the solution I need as well. Thank you very much.
José
0

#249 User is offline   Fe'wald 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-July 12
  • Location:RF, Moscow

Posted 15 July 2013 - 06:11 AM

Hello.
I'me a newbie and may be there is nothing new, but i've got an extended form element list for this multimodelform from Yii Booster components.

I'm just change inheritance in MultiModelForm.php from native yii CForm & CActiveForm classes to YiiBooster TbForm & TbActiveForm.
Additionally, you have to import needed class before this extending. Like this:
Yii::import('bootstrap.widgets.TbForm');
class MultiModelRenderForm extends TbForm



So i can call as form element type anything from this list:
public static $tbActiveFormMethods = array(
		'text' => 'textFieldRow',
		'password' => 'passwordFieldRow',
		'textarea' => 'textAreaRow',
		'file' => 'fileFieldRow',
		'radio' => 'radioButtonRow',
		'checkbox' => 'checkBoxRow',
		'listbox' => 'dropDownListRow',
		'dropdownlist' => 'dropDownListRow',
		'checkboxlist' => 'checkBoxListRow',
		'radiolist' => 'radioButtonListRow',
		//HTML5 types not supported in YiiBooster yet: render as textField
		'url' => 'textFieldRow',
		'email' => 'textFieldRow',
		'number' => 'textFieldRow',
		//'range'=>'activeRangeField', not supported yet
		'date' => 'datepickerRow',
		//new YiiBooster types
		'captcha' => 'captchaRow',
		'daterange' => 'dateRangeRow',
		'redactor' => 'redactorRow',
		'markdowneditor' => 'markdownEditorRow',
		'uneditable' => 'uneditableRow',
		'radiolistinline' => 'radioButtonListInlineRow',
		'checkboxlistinline' => 'checkBoxListInlineRow',
		'select2' => 'select2Row'
	);


Now I'm trying to get this wysiwyg editors work well.

This post has been edited by Fe'wald: 16 July 2013 - 06:01 AM

0

#250 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 485
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 15 July 2013 - 11:55 AM

Thanks for the information but I'm still not clear; are you saying that if I change these lines in MultiModelForm.php:
...
class MultiModelRenderForm extends CForm
{
...
class MultiModelEmbeddedForm extends CActiveForm
{
...


to these:
...
class MultiModelRenderForm extends bootstrap.widgets.TbForm
{
...
class MultiModelEmbeddedForm extends bootstrap.widgets.TbActiveForm
{
...


that I'll be able to use Ajax calls on my dropDownListRow? Please clarify, thanks!
José
0

#251 User is offline   Fe'wald 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-July 12
  • Location:RF, Moscow

Posted 16 July 2013 - 05:57 AM

No, i'm not assume this. Inheritance from the extended classes provide you to render some additional elements but there are still many issues with getting all of js working properly after relCopy. My first post is hasty.

In my project i want to render any wysiwyg editor instead of this textareas but after coping this editors work buggy - any buttons from the second instance affect the first instance. I think it because of brutish copying. May be, i have to change some id's and recall some init js everytime you create a copy. Perhaps, this is a deadlock.

About you question: dont know, i will need some ajax but later.
0

#252 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 485
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 16 July 2013 - 02:38 PM

Ok, thanks for the help!
José
0

#253 User is offline   mentorq 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 105
  • Joined: 26-June 13

Posted 31 July 2013 - 01:18 AM

Hi there. I want to ask if anyone know how to set default value for generated textfields.

Example: I want to get 1 textfield with money f.e. 3000$. If I click 'add item' and i get +1 field I need to get it value as 3000$/1. Next 'add item' and default value for all textfields is 3000$/2, next 3000$/3 etc...

How should I do this? It's all new to me so any help would be appreciated. Thx ;)
0

#254 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 485
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 23 August 2013 - 01:36 PM

I'm no JavaScript expert so after a lot of hair pulling (and kudos to @Arely and @Paul_Kish) I was finally able to get Ajax working for my dropdowns. In my invoice form line items (inventory_id, qty, price) the price gets loaded through Ajax and if it's tagged as a fixed price then the price text input is disabled. The remaining problem is that after cloning a line item if its predecessor price was disabled then the clone inherits the disabled attribute.

I've tried resetting it with the jsAfterNewId option:
'jsAfterNewId' => "
	if(this.attr('id').indexOf('TSvctixln_price') >= 0)
	{
		this.attr('disabled', 'false');
	}
",


but it's always disabled. I also tried resetting it in the change script:
<?php
Yii::app()->clientScript->registerScript('fetchprice',
	$('.litem').change(function()
	{
		var itmprice = $(this).parents('td').next().find('.lprice');
		$.post('/svctix/fetchinvpricing',$(this).serialize(),function(data)
		{
			itmprice.val(data.price);
			if(data.fixedp == '1') {itmprice.attr('disabled', 'true');} else {itmprice.attr('disabled', 'false');}
		},
		'json'
		);
	});
	",
	CClientScript::POS_READY
);


but that doesn't reset it either. Any ideas?

Thanks for your help,
José
0

#255 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 485
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 24 August 2013 - 06:17 AM

Never mind, I found a syntax error and solved the problem :rolleyes:
José
0

#256 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 02-July 13

Posted 30 October 2013 - 12:58 AM

Hi, I've been using extension
jqrelcopy, with duplicate TimePicker in my form. But to clone the 2nd, MyTimePicker don't work.
Always working in the TimePicker 1.
<div class="row copy">
    <div class="span2">
        <?php echo $form->timepickerRow(
                $model,'jamkerja',array(
                'class' => 'input-small','empty','options'=>array('showMeridian'=>false)
                )
        ); ?>
        <?php // echo $form->hiddenField($model,'shift_kerja[]'); ?>
    </div>
        <div class="span2">
                <?php echo $form->timepickerRow(
                $model,'jamistirahat',array(
                'class' => 'input-small','options'=>array('showMeridian'=>false)
                )
        ); ?>
        </div>    
        </div>

0

#257 User is offline   Joblo 

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

Posted 30 October 2013 - 01:21 AM

The jqrelcopy is a bit out of date and is not tested with timepicker or other jquery based components.

The problem is always the same: you have to execute extra js-code after cloning the input to bind the cloned elements with the new id to the js-functions.

Did you try the newer extension recopy instead?

Or maybe you can try the multimodelform extension instead. This comes with support for the datetimepicker, but read the chapter Usage widget form elements from the documentation first.
0

#258 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 02-July 13

Posted 30 October 2013 - 01:26 AM

View PostJoblo, on 30 October 2013 - 01:21 AM, said:

The jqrelcopy is a bit out of date and is not tested with timepicker or other jquery based components.

The problem is always the same: you have to execute extra js-code after cloning the input to bind the cloned elements with the new id to the js-functions.

Did you try the newer extension recopy instead?

Or maybe you can try the multimodelform extension instead. This comes with support for the datetimepicker, but read the chapter Usage widget form elements from the documentation first.

Thanks Joblo.. :)
0

#259 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 02-July 13

Posted 01 November 2013 - 06:04 PM

Hi Joblo,About multimodelform.
How do I add a hidden input increment if every click turn on? And How do I give a limit for dynamic row???
:rolleyes:
0

#260 User is offline   Joblo 

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

Posted 01 November 2013 - 06:18 PM

hidden input:

Assign a hidden input in the formbuilder/formConfig and use the jsAfterNewId (or the jsAfterCloneCallback) property to increment the value.

limit:
Set the properties 'limit' and 'limitText' of the MultiModelForm widget

Read the documentation or take a look at the source.
0

Share this topic:


  • (14 Pages)
  • +
  • « First
  • 11
  • 12
  • 13
  • 14
  • 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