Yii Framework Forum: [solved]mau nanya CJuiAutocomplete - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[solved]mau nanya CJuiAutocomplete Rate Topic: -----

#1 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

  Posted 10 January 2011 - 10:30 PM

teman2 mau nanya nih
kok field yang kupasang auto complete ga kesimpen yah..
mungkin dia ga kebaca untuk ke save...

Quote

Posted Image


jadinya pas di input begini:

Quote

Posted Image

berikut sintaks di viewnya
<div class="row">
		<?php echo $form->labelEx($model,'product_number'); ?>
		<?php //echo $form->textField($model,'product_number',array('size'=>60,'maxlength'=>128));?>
		<?php
		$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name'=>'product_number',
    'source'=>$this->createUrl('productintegration/autocompleteTest'),
    // additional javascript options for the autocomplete plugin
    'options'=>array(
        'minLength'=>'2',
    ),
    'htmlOptions'=>array(
        'style'=>'height:20px;'
    ),
));
?>


apakah ada yang salah sehingga attribut 'product_number' ga kebaca sehingga tidak kesave ke database yah?

mohon bantuan kk..
take it or leave it
0

#2 User is offline   fastcrash 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 10-March 10
  • Location:South Jakarta

Posted 10 January 2011 - 10:57 PM

untuk tau data sdh terkirim setelah submit bisa gunakan print_r di controller
...

echo "<pre>";
print_r($model->attributes=$_POST['product']);  //nama model class product
echo "</pre>";
die();

if($model->save())					  
    $this->redirect(array('view','id'=>$model->ID_product));

...



klo blum masuk, brarti masih ada yg salah di view form atau blum didefinisikan di model.
0

#3 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 10 January 2011 - 11:11 PM

View Postfastcrash, on 10 January 2011 - 10:57 PM, said:

untuk tau data sdh terkirim setelah submit bisa gunakan print_r di controller
...

echo "<pre>";
print_r($model->attributes=$_POST['product']);  //nama model class product
echo "</pre>";
die();

if($model->save())					  
    $this->redirect(array('view','id'=>$model->ID_product));

...



klo blum masuk, brarti masih ada yg salah di view form atau blum didefinisikan di model.


kan kalo begini :
<?php echo $form->labelEx($model,'product_number'); ?>
<?php echo $form->textField($model,'product_number',array('size'=>60,'maxlength'=>128));?>
<?php echo $form->error($model,'product_number'); ?>

itu kesimpen bang....

tapi kalo saya implement Cjuiautocomplete seperti :
<?php echo $form->labelEx($model,'product_number'); ?>
		<?php //echo $form->textField($model,'product_number',array('size'=>60,'maxlength'=>128));?>(ini kumatiin)
		<?php
		$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name'=>'product_number',
    'source'=>$this->createUrl('productintegration/autocompleteTest'),
    // additional javascript options for the autocomplete plugin
    'options'=>array(
        'minLength'=>'2',
    ),
    'htmlOptions'=>array(
        'style'=>'height:20px;'
    ),
));
?>
		
		<?php echo $form->error($model,'product_number'); ?>

jadinya ga kebaca,
bukankah kita cuma perlu membuat atribut namenya(dalam widget) menjadi 'product number'????
take it or leave it
0

#4 User is offline   fastcrash 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 10-March 10
  • Location:South Jakarta

Posted 11 January 2011 - 12:12 AM

coba name-nya berupa array, input value di yii berupa array()

'name'=>'product[product_number]',

0

#5 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 11 January 2011 - 12:35 AM

View Postfastcrash, on 10 January 2011 - 10:57 PM, said:

untuk tau data sdh terkirim setelah submit bisa gunakan print_r di controller
...

echo "<pre>";
print_r($model->attributes=$_POST['product']);  //nama model class product
echo "</pre>";
die();

if($model->save())					  
    $this->redirect(array('view','id'=>$model->ID_product));

...




klo blum masuk, brarti masih ada yg salah di view form atau blum didefinisikan di model.

thanks kakak emang ga keiisi rupanya

aku mau nanya lagi
kan kalo :
<?php echo $form->labelEx($model,'product_number'); ?>
<?php echo $form->textField($model,'product_number',array('size'=>60,'maxlength'=>128));?>
<?php echo $form->error($model,'product_number'); ?>
itu bakalan kesimpen
sedangkan setelah kupasang autocomplete jadi :
<?php echo $form->labelEx($model,'product_number'); ?>
<?php //echo $form->textField($model,'product_number',array('size'=>60,'maxlength'=>128));?>(inikumatiin)
<?php
		$this->widget('zii.widgets.jui.CJuiAutoComplete',array(
    'name'=>'product_number',
	'value'=>'',
    'sourceUrl'=>$this->createUrl('productintegration/autocompleteTest'),
    // additional javascript options for the autocomplete plugin
    'options'=>array(
        'minLength'=>'2',
    ),
    'htmlOptions'=>array(
        'style'=>'height:20px;'
    ),
));
?>
		
<?php echo $form->error($model,'product_number'); ?>

itu jadi ga kesimpen
bukannya atribut name di widget cjuinya cukup diganti jadi 'product_number' aja supaya itu kesimpen?
take it or leave it
0

#6 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 11 January 2011 - 12:40 AM

View Postfastcrash, on 11 January 2011 - 12:12 AM, said:

coba name-nya berupa array, input value di yii berupa array()

'name'=>'product[product_number]',


tetep masih belumm kebaca kakak..
hmmmm...
saya juga masih mikir nih
but thanks dah mau ngebantu kk
take it or leave it
0

#7 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 11 January 2011 - 12:55 AM

View Postressaince, on 11 January 2011 - 12:40 AM, said:

tetep masih belumm kebaca kakak..
hmmmm...
saya juga masih mikir nih
but thanks dah mau ngebantu kk

udah berhasil bang

dikasih 'attribute' sama 'model'

sip2
take it or leave it
0

#8 User is offline   fastcrash 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 10-March 10
  • Location:South Jakarta

Posted 11 January 2011 - 12:55 AM

ok. ;D

Soalnya ane jg coba and berhasil, tanpa set attribut
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
		'name'=>'t_profile[kabupaten]',
		'source'=>array('ac123', 'ac223', 'ac333'),
		// additional javascript options for the autocomplete plugin
		'options'=>array(
			'minLength'=>'2',
		),
		'htmlOptions'=>array(
			'style'=>'height:20px;'
		),
	));


klo di print_r($model->attributes=$_POST['t_profile']) di controller, hasilnya
Array
(
    [kabupaten] => ac333
)

0

#9 User is offline   Peter JK 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 84
  • Joined: 22-November 10
  • Location:Jakarta, Indonesia

Posted 29 January 2011 - 06:19 AM

Jangan lupa masukin Modelnya, Gan...


<div class="row">
<?php echo $form->labelEx($model,'product_number'); ?>
<?php //echo $form->textField($model,'product_number',array('size'=>60,'maxlength'=>128));?>
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
//Gini Caranya
'model'=>$model,
'attribute'=>'product_number',
//Yang 'name' nggak usah
//'name'=>'product_number',
//Tambah yang ini juga
'value'=>$this->createUrl('productintegration/autocompleteTest'),
//SEMOGA BERHASIL.....HEHE
'source'=>$this->createUrl('productintegration/autocompleteTest'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
?>
0

Share this topic:


Page 1 of 1
  • 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