Yii Framework Forum: Forms in Bootstrap Modal with Ajax submit button - Yii Framework Forum

Jump to content

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

Forms in Bootstrap Modal with Ajax submit button Rate Topic: -----

#1 User is offline   konstrukt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 23-February 12

Posted 21 June 2012 - 03:27 AM

I copied the login form that comes with the Yii in a bootstrap Modal. Also used a 'ajaxSubmitButton' for the submit button. My goal is to log the user in using ajax. The problem I encountered is that no variable is posted to the controller (I checked with Firebug). Can anyone help me figure out what is going wrong?

Thanks!

Here is the code for the Modal in my view:


<div class="modal hide" id="login">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">x</button>
		<h3>Log in</h3>
	</div>
	<div class="modal-body">

		<div class="form">
		<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'login-form',
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
		),
		)); ?>

			<p class="note">
				Fields with <span class="required">*</span> are required.
			</p>

			<div class="row">
			<?php echo $form->labelEx($model,'username'); ?>
			<?php echo $form->textField($model,'username',array ('name' => 'Mohamamd', 'id'=>'Mohamamd2', 'value'=>'value')); ?>
			<?php echo $form->error($model,'username'); ?>
			</div>

			<div class="row">
			<?php echo $form->labelEx($model,'password'); ?>
			<?php echo $form->passwordField($model,'password'); ?>
			<?php echo $form->error($model,'password'); ?>
			</div>

			<div class="row rememberMe">
			<?php echo $form->checkBox($model,'rememberMe'); ?>
			<?php echo $form->label($model,'rememberMe'); ?>
			<?php echo $form->error($model,'rememberMe'); ?>
			</div>



			<?php $this->endWidget(); ?>
		</div>
		<!-- form -->
	</div>
	<div class="modal-footer">
		<a href="#" class="btn" data-dismiss="modal">Close</a>
		<?php echo CHtml::ajaxSubmitButton('Login', array('index'), array('update'=>'#searchResults'),
		array("class"=>"btn btn-primary btn-large")
		);
		?>
	</div>
</div>



0

#2 User is offline   micz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 05-June 09

Posted 28 June 2012 - 04:20 AM

Shouldn't your submit button be inside form?
0

#3 User is offline   saada 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-September 12

Posted 15 October 2012 - 12:26 AM

I'm having the exact same problems!
Nothing works!
0

#4 User is offline   Ujjwal Prajapati 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 47
  • Joined: 24-April 12

Posted 15 October 2012 - 12:42 AM

<div class="modal hide" id="login">
        <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">x</button>
                <h3>Log in</h3>
        </div>
        <div class="modal-body">

                <div class="form">
                <?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'login-form',
        'enableClientValidation'=>true,
        'clientOptions'=>array(
                'validateOnSubmit'=>true,
                ),
                )); ?>

                        <p class="note">
                                Fields with <span class="required">*</span> are required.
                        </p>

                        <div class="row">
                        <?php echo $form->labelEx($model,'username'); ?>
                        <?php echo $form->textField($model,'username',array ('name' => 'Mohamamd', 'id'=>'Mohamamd2', 'value'=>'value')); ?>
                        <?php echo $form->error($model,'username'); ?>
                        </div>

                        <div class="row">
                        <?php echo $form->labelEx($model,'password'); ?>
                        <?php echo $form->passwordField($model,'password'); ?>
                        <?php echo $form->error($model,'password'); ?>
                        </div>

                        <div class="row rememberMe">
                        <?php echo $form->checkBox($model,'rememberMe'); ?>
                        <?php echo $form->label($model,'rememberMe'); ?>
                        <?php echo $form->error($model,'rememberMe'); ?>
                        </div>
                       
                       <div class="modal-footer">
                         <a href="#" class="btn" data-dismiss="modal">Close</a>
                 <?php echo CHtml::ajaxSubmitButton('Login', array('index'), array('update'=>'#searchResults'),
                array("class"=>"btn btn-primary btn-large")
                );
                ?>
        </div>


                        <?php $this->endWidget(); ?>
                </div>
                <!-- form -->
        </div>
        
</div>


This should work!
0

#5 User is offline   Sage 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 29-August 12
  • Location:California, USA

Posted 17 January 2013 - 06:08 PM

Ever get this to work? I'm also trying to accomplish a modal login.
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