Thanks Joblo for fast reply
like this :
‘jsAfterNewId’ => MultiModelForm::afterNewIdDateTimePicker($memberFormConfig[‘elements’][‘jamkerja’]),
for limit still not working for child input…limit max 3.
Thanks Joblo for fast reply
like this :
‘jsAfterNewId’ => MultiModelForm::afterNewIdDateTimePicker($memberFormConfig[‘elements’][‘jamkerja’]),
for limit still not working for child input…limit max 3.
HI, I just download and start using multimodelform , i have a problem with it
when I submit form data , i get an error
[font=Verdana][size=2]mb_strlen() expects parameter 1 to be string, array given[/size][/font]
[font=Verdana][/font]
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?
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,<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' /> -> $validatedMembers,$deleteMembers <- <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />?,$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())
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
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 ?
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.
Hello friends,
I am geeting error to insllating this extension
What i want to develope is :
Customer
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)),
));
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.
How do I put AddLink after the table?
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.
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?
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.
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.
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!
sir i have error in the update action, see the first picture, then when i fix the validation error i receive error see 2nd picture.