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

Jump to content

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

#261 User is offline   masdib.banget 

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

Posted 01 November 2013 - 06:49 PM

View PostJoblo, on 01 November 2013 - 06:18 PM, said:

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.

Thanks Joblo for fast reply
like this :
'jsAfterNewId' => MultiModelForm::afterNewIdDateTimePicker($memberFormConfig['elements']['jamkerja']), ::)
for limit still not working for child input..limit max 3.
0

#262 User is offline   EmadGh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 13-April 12
  • Location:Kashmar

Posted 31 January 2014 - 06:51 AM

HI, I just download and start using multimodelform , i have a problem with it
when I submit form data , i get an error

mb_strlen() expects parameter 1 to be string, array given


0

#263 User is offline   Ednei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 16-May 13

Posted 12 February 2014 - 01:12 PM

Hi!

I configured my actionCreate() like below:

	public function actionCreate() {
    	
    	Yii::import('ext.multimodelform.MultiModelForm');
    	
    	$model = new Vendas;
    	
    	//initialize the vars for multimodelform
	$vendaProduto = new VendaProduto();
	$validatedProdutos = array();

    	// Uncomment the following line if AJAX validation is needed
    	// $this->performAjaxValidation($model);

    	if (isset($_POST['Vendas'])) {
        	$model->attributes = $_POST['Vendas'];
        	if (MultiModelForm::validate($vendaProduto,$validatedProdutos,$deleteItems) && $model->save()){
            	//the foreign key values for the produtos
            	$masterValues = array ('venda_id'=>$model->id);
            	
        	if (MultiModelForm::save($vendaProduto,$validatedMembers,$deleteMembers,$masterValues))
                    	$this->redirect(array('view', 'id' => $model->id));
        	}
    	}


    	$this->render('create', array(
        	'model' => $model,
        	'vendaProduto'=>$vendaProduto, 
        	'validatedProdutos' => $validatedProdutos,
    	));
	}


but, the MultiModelForm::validate() return false! Someone's know whats happening?
0

#264 User is offline   Joblo 

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

Posted 13 February 2014 - 01:13 AM

If MultiModelForm::validate()returns false, a input validation (checking the model rules()) fails. There should be errors displayed.
Check the errorSummary in the view code too.

Another issue:

You have to use the same variables if you split validate() and save().


if (MultiModelForm::validate($vendaProduto,$validatedProdutos,$deleteItems) && ..
{

...
if (MultiModelForm::save($vendaProduto,??? -> $validatedMembers,$deleteMembers <- ????,$masterValues))
}

1

#265 User is offline   Ednei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 16-May 13

Posted 13 February 2014 - 01:09 PM

View PostJoblo, on 13 February 2014 - 01:13 AM, said:

If MultiModelForm::validate()returns false, a input validation (checking the model rules()) fails. There should be errors displayed.
Check the errorSummary in the view code too.

Another issue:

You have to use the same variables if you split validate() and save().


if (MultiModelForm::validate($vendaProduto,$validatedProdutos,$deleteItems) && ..
{

...
if (MultiModelForm::save($vendaProduto,??? -> $validatedMembers,$deleteMembers <- ????,$masterValues))
}


Tks! I followed your tips and now its working. The problem was a rule defined for the venda_id attribute (required). I just deleted this rule (after all the line
$masterValues = array('venda_id'=>$model->id);
set this attribute value in actionCreate()) ::)
0

#266 User is offline   overload 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 28-June 12

Posted 14 February 2014 - 12:47 PM

Hi all,

I'm trying to disable (read only) recorded elements and to leave writable new inputs but with no success...

$formConfig = array(

        'elements'=>array(

          'offer'=>array(
            'type'=>'text',
            'maxlength'=>140,
            'style' => 'width: 380px',
            'disabled'=>($model->status == 1 && !Yii::app()->user->checkAccess('admin')) ? 'disabled' : '',
          ),
));


Can someone explain me how to do this, please?
thanks
0

#267 User is offline   JFReyes 

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

Posted 14 February 2014 - 01:41 PM

I tried something like that in my project and couldn't get it to work so I ended up doing it in JavaScript:

$isadm = CJavaScript::encode(Yii::app()->user->isUserAdmin());
Yii::app()->clientScript->registerScript('fetchprice',
	"var isadm = '$isadm';
	$('.litem').change(function() // class litem is the 1st element in the MMF row
	{
		var itmprice = $(this).parents('td').next().find('.lprice'); // class lprice is the element to enable/disable
		$.post('/svctix/fetchinvpricing',$(this).serialize(),function(data)
		{
			itmprice.val(data.price);
			if(isadm == 'false' && data.fixedp == '1')
			{
				itmprice.attr('readonly', true);
			}
			else
			{
				itmprice.attr('readonly', false);
			}
		},
		'json'
		);
	});
	",
	CClientScript::POS_READY
);

?>

José
0

#268 User is offline   overload 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 28-June 12

Posted 17 February 2014 - 06:19 AM

View PostJFReyes, on 14 February 2014 - 01:41 PM, said:

I tried something like that in my project and couldn't get it to work so I ended up doing it in JavaScript:

$isadm = CJavaScript::encode(Yii::app()->user->isUserAdmin());
Yii::app()->clientScript->registerScript('fetchprice',
	"var isadm = '$isadm';
	$('.litem').change(function() // class litem is the 1st element in the MMF row
	{
		var itmprice = $(this).parents('td').next().find('.lprice'); // class lprice is the element to enable/disable
		$.post('/svctix/fetchinvpricing',$(this).serialize(),function(data)
		{
			itmprice.val(data.price);
			if(isadm == 'false' && data.fixedp == '1')
			{
				itmprice.attr('readonly', true);
			}
			else
			{
				itmprice.attr('readonly', false);
			}
		},
		'json'
		);
	});
	",
	CClientScript::POS_READY
);

?>



Thanks JFReyes but i need a php way of doing this...
Does anyone have a solution ?
0

#269 User is offline   NCS_One 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 24-August 11

Posted 19 February 2014 - 10:42 AM

Hi,

When I click "Add item" it inserts a new row in the html with the "Remove" link but doesn't add any inputs.
What could be the issue?

Thanks.
0

#270 User is offline   Yatin Mistry 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 11-March 14

Posted 12 March 2014 - 09:12 AM

Hello friends,

I am geeting error to insllating this extension
What i want to develope is :
1. Customer
2. contact persons <-- multiple in one form based on customer_id


below is the error
Property "MultiModelForm.errorIndexes" is not defined.

public function actionCreate()
	{
		Yii::import('ext.multimodelform.MultiModelForm');
		$model=new MmCustomer;
		
		//initialize the vars for multimodelform
		$MmContactperson = new MmContactperson;
		$errorIndex = null;

		// Uncomment the following line if AJAX validation is needed
		 $this->performAjaxValidation($model);

		if(isset($_POST['MmCustomer']))
		{
			$model->attributes=$_POST['MmCustomer'];
			
			//the foreign key values for the contact person
			$masterValues = array ('customer_id'=>$model->customer_id);
			
			if($model->save() && MultiModelForm::save($MmContactperson,$errorIndexes,$masterValues))
			{
				if(@$_POST['add']!='')
					$this->redirect(array('admin','id'=>$model->customer_id,'msg'=>'Add'));
				else if(@$_POST['save_and_new']!='')
			    	$this->redirect(array('create'));
				
			}	
		}

		$this->render('create',array(
			'model'				=>	$model,
			'MmContactperson'		=> $MmContactperson,
			'errorIndexes' 		=> $errorIndexes,
			'validatedItems' 	=> $updateItems,
		));
	}




customer model
public function getMultiModelForm()
	{
		//Can be a config file that returns the configuration too
		// return 'pathtoformconfig.formconfig';

		return array(
		  'elements'=>array(
			'contactperson_id'=>array(
						'type'		=> 'text',
						'maxlength'	=> 10,
			),
			'contactperson_name'=>array(
						'type'		=> 'text',
						'maxlength'	=> 40,
			),
			'mobile'	=>array(
									'type'		=> 'text',
									'maxlength'	=> 40,
						),
		  	'email'	=>array(
						'type'		=> 'text',
						'maxlength'	=> 40,
		  	),
			'skypeid'	=>array(
						'type'		=> 'text',
						'maxlength'	=> 40,
		  	),
			'gtalk_id'	=>array(
						'type'		=> 'text',
						'maxlength'	=> 40,
		  	),
			
			
		));
	}


_form.php
//render the member models
	$this->widget('ext.multimodelform.MultiModelForm',array(
			//a unique widget id
			'id' => 'contactperson_id',  
			
			//the text for the remove record link
			'removeText' => 'Remove', 
			
			//see the render call in the controller actions create/update 
			//instance of the member model, 
			'model' => $MmContactperson,  
			
			//array of positions with invalid records
			'errorIndexes' => $errorIndexes, 
			 'tableView' => true,
			
			//array of member models
			'validatedItems' => $validatedItems, 
			
			//array of member models as list of editable members
			'data' => $MmContactperson->findAll('customer_id=:customer_id', array(':customer_id'=>$model->customer_id)),
		));

0

#271 User is offline   Joblo 

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

Posted 12 March 2014 - 09:26 AM

Thats right, the multimodelform has no 'errorIndexes' or 'updateItems'.
The validateditems are the second parameter of MultimodelForm::save():



public function actionCreate()
        {
                Yii::import('ext.multimodelform.MultiModelForm');
                $model=new MmCustomer;
                
                //initialize the vars for multimodelform
                $MmContactperson = new MmContactperson;


               // $errorIndex = null; <-- wrong
               $validatedItems = array();


                // Uncomment the following line if AJAX validation is needed
                 $this->performAjaxValidation($model);

                if(isset($_POST['MmCustomer']))
                {
                        $model->attributes=$_POST['MmCustomer'];
                        
                        //the foreign key values for the contact person
                        $masterValues = array ('customer_id'=>$model->customer_id);
                        
//<--  use validatedItems as second parameter                        
if($model->save() && MultiModelForm::save($MmContactperson,$validatedItems,$masterValues))
                        {
                                if(@$_POST['add']!='')
                                        $this->redirect(array('admin','id'=>$model->customer_id,'msg'=>'Add'));
                                else if(@$_POST['save_and_new']!='')
                                $this->redirect(array('create'));
                                
                        }       
                }

                $this->render('create',array(
                        'model'                         =>      $model,
                        'MmContactperson'               => $MmContactperson,
                        //'errorIndexes'          => $errorIndexes,  <-- remove this
                        'validatedItems'        => $validatedItems,
                ));
        }



And remove
'errorIndexes' => $errorIndexes, 
in the view too.
0

#272 User is offline   Eder Lima 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-August 11

Posted 26 May 2014 - 12:34 PM

How do I put AddLink after the table?
0

#273 User is offline   Joblo 

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

Posted 27 May 2014 - 02:30 AM

The addlink is always rendered at the top.
But maybe you can try to change the position in css for the css-class mmf_addlink or mmf_additem.
0

#274 User is offline   IRCSASW 

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

Posted 05 June 2014 - 06:43 PM

Hello,

I have the following problem with the extension.
While processing the update of 46 items, under $validatedItems only receives 28, works well for transactions less items.

In MultimodelForm.php (6.0.0) line 794:
if (!empty($validatedItems))
{var_dump($validatedItems); die();}


Result:
array (size=28)
...


Any idea?

sorry for my GoogEnglish!!
Arturo Ramos
www.ircsasoftware.com.mx
Cancún, México
0

#275 User is offline   IRCSASW 

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

Posted 05 June 2014 - 10:41 PM

View PostIRCSASW, on 05 June 2014 - 06:43 PM, said:

Hello,

I have the following problem with the extension.
While processing the update of 46 items, under $validatedItems only receives 28, works well for transactions less items.

In MultimodelForm.php (6.0.0) line 794:
if (!empty($validatedItems))
{var_dump($validatedItems); die();}


Result:
array (size=28)
...


Any idea?

sorry for my GoogEnglish!!


The data in $_POST are not complete.

var_dump($_POST['Partidas']['u__']); die();


It only shows 27 items and a part of the 28.

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

#276 User is offline   Joblo 

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

Posted 06 June 2014 - 01:20 AM

Seems to be an issue of POST_MAX_SIZE.
0

#277 User is offline   IRCSASW 

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

Posted 07 June 2014 - 12:23 PM

View PostJoblo, on 06 June 2014 - 01:20 AM, said:

Seems to be an issue of POST_MAX_SIZE.


No matter how big do value, POST always cut in the same place, the same on the web server on my localhost.

Since I increased the value of POST_MAX_SIZE but I still have the problem. I know it's not the topic, but what other way to get that data?

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

#278 User is offline   IRCSASW 

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

Posted 07 June 2014 - 11:08 PM

I pass the tip of the solution in case anyone happens.

The problem was not the variable POST_MAX_SIZE, MAX_INPUT_VARS is the variable.

in index.php in the root of the project:
ini_set("max_input_vars","2000");


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

#279 User is offline   mixi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 24-January 14

Posted 23 July 2014 - 06:42 AM

Hello Joblo,

Can you please help me, I am stuck right now. I use you extension that is great extension by the way!
I use CJuiAutoComplete field type, and it only work once. For first field it works, and when I generate another fields (Add item), my second field with CJuiAutoComplete type does not work.
Here is my code:
$carServiceItemsFormConfig = array(
'elements'=>array(
'ordinal_number'=>array(
'type'=>'text',
'maxlength'=>40,
),
'car_part_component_id'=>array(
'type'=>'zii.widgets.jui.CJuiAutoComplete',
'model'=>CarServiceItems::model(),
'attribute'=>'car_part_component_id',
'name'=>'car_part_component_autocomplete',
'source'=>$this->createUrl('carPartComponents/carPartComponentsAutoComplete'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
),
'htmlOptions'=>array(
'style'=>'height:20px;',
'class'=>'span5',
'placeholder'=>Yii::t('shared','Start typing...'),
),
),
'activity'=>array(
'type'=>'text',
'maxlength'=>40,
),
));

I am newbie, but I think that is some problem with some same script ids or something like that.
Thanks in advance!
0

Share this topic:


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