Need Help With Form

Hi, My name is Dennis and I’m quite new to yii

As much as I like the framework I can’t get my form to work as I want it to, it say’s it’s blank when it’s actually not. This might be because they aren’t text fields anymore. but I’m not sure. if someone could help me out or link me to the answer I need that did be great :)

Code :


<div class="row">

		<?php echo $form->labelEx($model,'merk'); ?>

		<?php   echo $form->dropDownList(Merk::model(),'merk_id', CHtml::listData(Merk::model()->findAll(array('order' => 'merk_id')),'merk_id','merk_naam'));?>

		<?php echo $form->error($model,'merk'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'omschrijving'); ?>

		<?php echo $form->textField($model,'omschrijving',array('size'=>60,'maxlength'=>128)); ?>

		<?php echo $form->error($model,'omschrijving'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'aanschafdatum'); ?>

		<?php echo $form->textField($model,'aanschafdatum'); ?>

		<?php echo $form->error($model,'aanschafdatum'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'aanschafprijs'); ?>

		<?php echo $form->textField($model,'aanschafprijs',array('size'=>10,'maxlength'=>10)); ?>

		<?php echo $form->error($model,'aanschafprijs'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'filiaal'); ?>

		<?php echo $form->dropDownList(Filiaal::model(),'Filiaal_id', CHtml::listData(Filiaal::model()->findAll(array('order' => 'Filiaal_id')),'Filiaal_id','Filiaal_naam'));?>

		<?php echo $form->error($model,'filiaal'); ?>

	</div>

Thanks in advance!

did you check the drop down list value?

use cvarDumper::Dump($_POSt);

for checking/debugging the post values.

/* moved to General Discussion */

4884

ss (2013-11-14 at 02.30.29).png

I used the CVarDumper to check the post values, which where all good. but it keeps showing my that fields cannot be blank.

I’ve got the same problem when I want to use a MaskedTextfield instead of a Textfield

And about the value of the drop down list, I think it’s a string.

I was wondering if bumping up a post is allowed, bump?

Hi Dennis,

The first 2 parameters for CActiveForm::dropDownList must be a model instance and an attribute name, just as you do for CActiveForm::textField.




<div class="row">

	<?php echo $form->labelEx($model,'merk'); ?>

	<?php echo $form->dropDownList($model,'merk', CHtml::listData(Merk::model()->findAll(array('order' => 'merk_id')),'merk_id','merk_naam'));?>

	<?php echo $form->error($model,'merk'); ?>

</div>

...

<div class="row">

	<?php echo $form->labelEx($model,'filiaal'); ?>

	<?php echo $form->dropDownList($model,'filiaal', CHtml::listData(Filiaal::model()->findAll(array('order' => 'Filiaal_id')),'Filiaal_id','Filiaal_naam'));?>

	<?php echo $form->error($model,'filiaal'); ?>

</div>



Hi softark,

I now see I get the data I want from the Chtml::ListData.

Thanks a bunch! exactly what I needed.