No POST data in login portlet


I have a problem with my login portlet: when I submit the login form, no POST data is submitted. Here is my code:




class LoginPortlet extends CPortlet


    public function init()


        $this->title = 'Login';




    protected function renderContent()


        $model=new LoginForm;


        // $_POST array is always empty







        $this->render('loginPortlet', array('model'=>$model));




<?php $form=$this->beginWidget('CActiveForm', array(


)); ?>

	<div class="row">

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

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

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


	<div class="row">

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

		<?php echo $form->passwordField($model,'password'); ?>

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


	<div class="row rememberMe">

		<?php echo $form->checkBox($model,'rememberMe'); ?>

		<?php echo $form->label($model,'rememberMe'); ?>

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


	<div class="row buttons">

		<?php echo CHtml::submitButton('Login'); ?>


<?php $this->endWidget(); ?>

What’s wrong ? Thank you for this great forum !


can you print_r($_POST) in protected function renderContent()

Yes, unfortunately, print_r($_POST) gives me an empty array :frowning:

Array ( )

what is your current controller/action code? maybe there is a redirect somewhere?

first do a check if($_POST) to see if you successfully post. If there is a redirect it will be $_GET.

I have the same problem, did you solve yours?

My view has a very basic form

<form action="#" method="post">

<input type="text" id="new_username" size="50"/>

<input type="text" id="new_name" size="50"/>

<input type="text" id="new_address" size="50"/>

<input type="submit" value="Save" id="savenewuserbutton" name="savenewuserbutton"/>


In my controller:

foreach($_POST as $key=>$value) {

    echo "<b>$key:</b> $value<br />";


When i test it i only get the button value, not the input fields:

savenewuserbutton: Save

You haven’t set the ‘name’ attribute in the form fields. Try this:

<input type="text" name="new_username" id="new_username" size="50"/>

<input type="text" name="new_name" id="new_name" size="50"/>

<input type="text" name="new_address" id="new_address" size="50"/>