Yii Framework Forum: Form doesn't return data - Yii Framework Forum

Jump to content

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

Form doesn't return data Rate Topic: -----

#1 User is offline   echo66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 06-May 10

Posted 06 May 2010 - 07:33 PM

Hi again.

I'm trying to get data from a form in a view.

The view is this one:

<html>
<head>
<style type="text/css">

.register-user-form{
position:relative;
left:+300px;
}

#labelT{
color:darkblue;
width:220px;
}

#valueT{
position:relative;
left:+200px;
top:-23px;
}

.quadro{
position:relative;
top:111px;
}

#quadro-imagem{

}

#quadro-texto{

}

</style>
</head>

<body>

<?php $form=$this->beginWidget('CActiveForm', array(
		'id'=>'registryform',
		'enableAjaxValidation'=>false,
	)); ?>
	
	<?php echo $form->errorSummary($model); ?>
	
	<div class="quadro">
		
		<div id="quadro-imagem">
			<?php echo CHtml::image($model->photo,'Imagem não encontrada',array('height'=>100,'width'=>100))?>
		</div>
		
		<div id="quadro-texto">
			<?php echo $form->textField($model,'photo')?>
		</div>
		
	</div>
	
	<div class="register-user-form">
		<div id="labelT">
			<?php echo $form->labelEx($model,'Nome'); ?>
		</div>
		<div id="valueT">
			<?php echo $form->textField($model,'name'); ?>
			<?php echo $form->error($model,'name'); ?>
		</div>
		
		<div id="labelT">
			<?php echo $form->labelEx($model,'Email'); ?>
		</div>
		<div id="valueT">
			<?php echo $form->textField($model,'email'); ?>
			<?php echo $form->error($model,'email'); ?>
		</div>
		
		<div id="labelT">
			<?php echo $form->labelEx($model,'Password'); ?>
		</div>
		<div id="valueT">
			<?php echo $form->passwordField($model,'password'); ?>
			<?php echo $form->error($model,'password'); ?>
		</div>
		
		<div id="labelT">
			<?php echo $form->labelEx($model,'Confirmar password'); ?>
		</div>
		<div id="valueT">
			<?php echo $form->passwordField($model,'confirmPassword'); ?>
			<?php echo $form->error($model,'confirmPassword'); ?>
		</div>
		
		<div id="labelT">
			<?php echo $form->labelEx($model,'Sexo'); ?>
		</div>
		<div id="valueT">
			<?php 
				$sexChoice = array('masculino'=>'masculino', 'feminino'=>'feminino');
				echo CHtml::activeRadioButtonList($model,'sex',$sexChoice,array('checked'=>true));
			?>
		</div>
		
		<div id="calendarForBirthday"></div>
		
		<div id="labelT">
			<?php echo $form->labelEx($model,'Aniversário'); ?>
		</div>
		<div id="valueT">
			<?php echo $form->textField($model,'birthday'); ?>
			<?php echo $form->error($model,'birthday'); ?>
		</div>
	
		<div id="labelT">
			<?php echo $form->labelEx($model,'Localização') ?>
		</div>
		<div id="valueT">
			<?php echo $form->textField($model,'location') ?>
			<?php echo $form->error($model,'location'); ?>
		</div>
		<div id="valueT">
			<?php $form->textField($model,'photo')?>
			<?php $form->error($model,'photo') ?>
		</div>
		
		<div id="valueT">
			<?php echo $form->labelEx($model,'verifyCode'); ?>
			<?php $this->widget('CCaptcha'); ?>
			<?php echo $form->textField($model,'verifyCode'); ?>
		</div>
		<div id="labelT">Please enter the letters as they are shown in the image above.
			<br/>Letters are not case-sensitive.</div>
		</div>
	
		
	</div>
		
	<div>
		<?php echo CHtml::submitButton($model->isNew ? 'Registar' : 'Actualizar'); ?>
	</div>
	
	
<?php $this->endWidget(); ?>

</body>

</html>


The model for the form is:

<?php

/**
 * protected/models
 */
class RegisterUserForm extends CFormModel{
	
	public $isInternal;
	public $identifier; //CLIP
	public $internal;
	public $name;
	public $email;
	public $sex;
	public $password;
	public $confirmPassword;
	public $photo;
	public $location;
	public $birthday;
	public $isNew;
	public $verifyCode;
	
	public function rules(){
		
		return array(
		
			array('name, sex, email, password, identifier','required'),
			
			array('sex','in','range'=>array('masculino','feminino')),
			
			array('password', 'compare', 'compareAttribute'=>'confirmPassword'),
			
			//array('identifier','clipIDValidate'),
			
			array('email','email'),
			
			array('photo','url'),
			
			//array('birthday','type','dateFormat'),
			
			array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd'))
		
		);
	}
	
}

?>


and the action in the controller is:

public function actionWhat(){
		
		$model = new RegisterUserForm;
		$model->isNew = true;
		
		if(isset($_POST['RegisterUserForm'])){
			$this->render('registryUser',array('model'=>$model));
		}
		else
			echo 'oioi';
			
		
	}


so...what am i doing wrong? i tried to make the forms and the views like the examples in CRUD...
0

#2 User is offline   echo66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 06-May 10

Posted 06 May 2010 - 09:10 PM

For someeeeee reason, this started to work...and i didn't change the code a bit o.O

So...you can erase this topic, if you want.
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