Trying to have an upload button in one of my modules... First thing, the view in the browser is messed since cannot see the physical button...
Anyone done this to help out?
Below is my view code...
<?php echo form_open_multipart($this->uri->uri_string(), 'class="form-horizontal"'); ?>
<fieldset>
<div class="control-group <?php echo form_error('products_product_title') ? `enter code here`'error' : ''; ?>">
<?php echo form_label('Product Title'. lang('bf_form_label_required'), 'products_product_title', array('class' => "control-label") ); ?>
<div class='controls'>
<input id="products_product_title" type="text" name="products_product_title" maxlength="50" value="<?php echo set_value('products_product_title', isset($products['products_product_title']) ? $products['products_product_title'] : ''); ?>" />
<span class="help-inline"><?php echo form_error('products_product_title'); ?></span>
</div>
<div class="control-group <?php echo form_error('products_product_path') ? 'error' : ''; ?>">
<?php echo form_label('Upload Card'. lang('bf_form_label_required'), 'products_product_path', array('class' => "control-label") ); ?>
<div class='controls'>
<input id="products_product_path" type="submit" name="submit_form" value="<?php echo set_value('products_product_path', isset($products['products_product_path']) ? $products['products_product_path'] : ''); ?>" />
<span class="help-inline"><?php echo form_error('products_product_path'); ?></span>
</div>
</div>
<div class="form-actions">
<br/>
<input type="submit" name="save" class="btn btn-primary" value="Create products" />
or <?php echo anchor(SITE_AREA .'/developer/products', lang('products_cancel'), 'class="btn btn-warning"'); ?>
</div>
</fieldset>
<?php echo form_close(); ?>
You're missing a close near the top, which is probably affecting it.
<fieldset>
<div class="control-group <?php echo form_error('products_product_title') ? `enter code here`'error' : ''; ?>">
<?php echo form_label('Product Title'. lang('bf_form_label_required'), 'products_product_title', array('class' => "control-label") ); ?>
<div class='controls'>
<input id="products_product_title" type="text" name="products_product_title" maxlength="50" value="<?php echo set_value('products_product_title', isset($products['products_product_title']) ? $products['products_product_title'] : ''); ?>" />
<span class="help-inline"><?php echo form_error('products_product_title'); ?></span>
</div>
</div> <!-- this div needs to be added -->
You close each control-group, before adding another control.
In Bonfire Ajax call, you can simply use class='ajax-form' in the open tag of yout form. so it should be
<?php echo form_open_multipart($this->uri->uri_string(), 'class="ajax-form"'); ?>
reference:
AJAX in Bonfire
Related
I am trying to add popovers tooltip in tagsinput text field. But its not working.
Here is my code:
<div class="form-group"><!-- form-group -->
<div class="col-lg-6" id="prefix_value_div_error" style="display:none">
<?php echo $form->labelEx($model,'prefix_value', array('class'=>'col-lg-4 control-label')); ?>
<div class="col-lg-7">
<?php echo $form->textField($model,'prefix_value',array('class'=>'form-control tagsinput popovers','id'=>'prefix_value',"data-placement"=>"top","data-content"=>Yii::t('app','model.callThresholdPlanMaster.prefix_value.desc') ,"data-trigger"=>"hover", "data-original-title"=>Yii::t('app','model.callThresholdPlanMaster.prefix_value'))); ?>
<div id="prefix_value_error">
<?php echo $form->error($model,'prefix_value'); ?>
</div>
</div>
</div>
</div>
i have used CButtonColumn inside TbGridView.On click of button i want a dialog from where i want to send mail to recepient.
My admin.php code:
array(
'class'=>'CButtonColumn',
'template'=>'{dialog}',
'buttons'=>array(
'dialog' => array(
'label'=>'Email',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/email_envelope.png',
'url'=>'Yii::app()->createUrl("todoList/OpenMailDialog", array("id"=>$data->to_do_id))',
'options'=>array(
'ajax'=>array(
'type'=>'POST',
'url'=>"js:$(this).attr('href')",
'update'=>'#dialog_id',
),
),
),
),
),
<div class="dialog_id" style="display:none;"></div>
My controller code is:
public function actionOpenMailDialog($id){
$model=$this->loadModel($id);
$this->render('createDialog',array('model'=>$model,));
}
My view code is:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'mailDialog',
'options'=>array(
'title'=>'View Message #'. $model->id,
'autoOpen'=>true,
'modal'=>'true',
'width'=>'auto',
'height'=>'auto',
),
));
echo $this->renderPartial('_formDialog', array('model'=>$model)); ?>
<?php $this->endWidget('zii.widgets.jui.CJuiDialog');?>
My _formDialog:
<div class="form" id="mailDialogForm">
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row col2">
<?php echo $form->labelEx($model,'email_from'); ?>
<?php echo $form->textField($model,'email_from',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_from'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'email_to'); ?>
<?php echo $form->textField($model,'email_to',array('size'=>60,'maxlength'=>150)); ?>
<?php echo $form->error($model,'email_to'); ?>
</div>
<div style="clear:both"></div>
<div class="row col2">
<?php echo $form->labelEx($model,'subject'); ?>
<?php echo $form->textField($model,'subject',array('size'=>60,'maxlength'=>250)); ?>
<?php echo $form->error($model,'subject'); ?>
</div>
<div style="clear:both"></div>
<div class="row">
<?php echo $form->labelEx($model,'message'); ?>
<?php echo $form->textArea($model,'message',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'message'); ?>
</div>
<div style="clear:both"></div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ?
'Send' :'Send',array('class' => 'btn')); ?>
</div>
I am not able to pop up dialog here.What is the solution?
i simply chaged my code like this and its working now.My admin.php code is like this:
array(
'class'=>'CButtonColumn',
'template'=>'{dialog}',
'buttons'=>array(
'dialog' => array(
'label'=>'Email',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/email_envelope.png',
'visible'=>'$data->user_id===Yii::app()->user->id?false:true',
'url'=>'Yii::app()->createUrl("todoList/openMailDialog", array("id"=>$data->to_do_id))',
),
),
),
My _formDialog.php code:
<div id="mailDialogForm">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'mail-form',
'enableAjaxValidation'=>true,
));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="rowcol">
<?php echo $form->labelEx($model,'email_from'); ?>
<?php echo $form->textField($model,'email_from',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_from'); ?>
</div>
<div class="rowcol">
<?php echo $form->labelEx($model,'email_to'); ?>
<?php echo $form->textField($model,'email_to',array('size'=>60,'maxlength'=>150,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_to'); ?>
</div>
<div style="clear:both"></div>
<div >
-----------------
</div>
<div class="rowbutton">
<?php echo CHtml::submitButton($model->isNewRecord ?
'Send' :'Send',array('class' => 'btn')); ?>
</div>
<?php $this->endWidget(); ?>
</div>
I have used submitButton in my view form and on click of the button I have to open a dialog i.e another view form. How can I achieve that?
My code for submit button is:
<?php
echo CHtml::submitButton('Mail to Client' ,array(
'onclick'=>'js:act()',
'id'=>'$model->marketing_id','name' => 'ApproveButton' ,'class'=>'btn btn-success'));?>
From javascript method act() I have called my controller.this button is in my admin form. The code of controller to call another view is:
$this->render('_compose',array('mailList'=>$mailList,'model'=>$model),FALSE,true);
This _compose view, I have to open in dialog form. My _Compose form code is :
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'mydialog',
'options'=>array(
'title'=>'Mail to client',
'autoOpen'=>true,
),
));
?>
<div class="form wide">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'reply-form1',
'enableAjaxValidation'=>false,
'htmlOptions' => array('enctype' => 'multipart/form-data'), // ADD THIS
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.For multiple recipients please seperate by comma</p>
<?php echo $form->errorSummary($model); ?>
<div class="row col2">
<?php echo $form->labelEx($model,'email_from'); ?>
<?php echo $form->textField($model,'email_from',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_from'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'email_to'); ?>
<?php echo $form->textField($model,'email_to',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_to'); ?>
</div>
<div style="clear:both"></div>
<div class="row">
<?php echo $form->labelEx($model,'message'); ?>
<?php echo $form->textArea($model,'message',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'message'); ?>
</div>
<div style="clear:both"></div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Send' : 'Send',array('class' => 'btn')); ?>
</div>
<?php $this->endWidget(); ?>
</div>
<?php $this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::link('Open Dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));?>
You could just use CJuiDialog for this:
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'mydialog',
'options'=>array(
'title'=>'Mail to client',
'autoOpen'=>false,
),
));
<div class="form wide">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'reply-form1',
'enableAjaxValidation'=>false,
'htmlOptions' => array('enctype' => 'multipart/form-data'), // ADD THIS
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.For multiple recipients please seperate by comma</p>
<?php echo $form->errorSummary($model); ?>
<div class="row col2">
<?php echo $form->labelEx($model,'email_from'); ?>
<?php echo $form->textField($model,'email_from',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_from'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'email_to'); ?>
<?php echo $form->textField($model,'email_to',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly')); ?>
<?php echo $form->error($model,'email_to'); ?>
</div>
<div style="clear:both"></div>
<div class="row">
<?php echo $form->labelEx($model,'message'); ?>
<?php echo $form->textArea($model,'message',array('rows'=>6, 'cols'=>50)); ?>
<?php echo $form->error($model,'message'); ?>
</div>
<div style="clear:both"></div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Send' : 'Send',array('class' => 'btn')); ?>
</div>
<?php $this->endWidget(); ?>
</div>
$this->endWidget('zii.widgets.jui.CJuiDialog');
/** End Widget **/
echo CHtml::link('Open Dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
This is my full coding,
<?php
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
if($username && $password){
$insert = mysql_query("INSERT INTO users VALUES('', '$username', '$password')");
$msg = "User is created successfully";
}
else{
$error = "Please fillup all required fields!";
}
}
?>
<form class="form-horizontal" action="settings_user.php" method="POST">
<div class="form-group"><label class="col-lg-2 control-label">User Name</label>
<div class="col-lg-4"><input type="text" name="username" placeholder="" class="form-control" autofocus>
</div>
</div>
<div class="form-group"><label class="col-lg-2 control-label">Password</label>
<div class="col-lg-4"><input type="password" name="password" placeholder="" class="form-control"></div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-sm btn-primary" name="submit" type="submit">ADD</button>
</div>
</div>
<?php echo $msg; ?>
<?php echo $error; ?>
</form>
two error message appears: Undefined index for $msg and $error
how can I fix this?
This might work. Instead of using 2 variables for "success" and "failure", use single variable and put the message accordingly. Initialize the variable globally.
<?php
$msg="";
if(isset($_POST['submit'])) {
$username = $_POST['username']; $password = $_POST['password'];
if($username && $password){
$insert = mysql_query("INSERT INTO users VALUES('', '$username', '$password')");
$msg = "User is created successfully";
}
else{
$msg = "Please fillup all required fields!";
}
}
?>
<html>
<body>
<form class="form-horizontal" action="settings_user.php" method="POST">
<div class="form-group"><label class="col-lg-2 control-label">User Name</label>
<div class="col-lg-4"><input type="text" name="username" placeholder="" class="form-control"
autofocus>
</div>
</div>
<div class="form-group"><label class="col-lg-2 control-label">Password</label>
<div class="col-lg-4"><input type="password" name="password" placeholder="" class="form-
control"></div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-sm btn-primary" name="submit" type="submit">ADD</button>
</div>
</div>
<?php echo $msg; ?>
</form>
</body>
</html>
i have been on this for a few hours,
I want to randomise the result and there has been not provision to do that from the backend.
<?php foreach( $this->friends as $membership ):
if( !isset($this->friendUsers[$membership->resource_id]) ) continue;
$member = $this->friendUsers[$membership->resource_id];
?>
<li id="user_friend_<?php echo $member->getIdentity() ?>">
<?php echo $this->htmlLink($member->getHref(), $this->itemPhoto($member, 'thumb.icon'), array('class' => 'profile_friends_icon')) ?>
<div class='profile_friends_body'>
<div class='profile_friends_status'>
<span>
<?php echo $this->htmlLink($member->getHref(), $member->getTitle()) ?>
</span>
<?php //echo $member->status; ?>
</div>
<?php if( $this->viewer()->isSelf($this->subject()) && Engine_Api::_()->getApi('settings', 'core')->getSetting('user.friends.lists')): // BEGIN LIST CODE ?>
<div class='profile_friends_lists' id='user_friend_lists_<?php echo $member->user_id ?>'>
<span class="pulldown" style="display:inline-block;" onClick="toggleFriendsPulldown(event, this, '<?php echo $member->user_id ?>');">
<div class="pulldown_contents_wrapper">
<div class="pulldown_contents">
<ul>
<?php foreach( $this->lists as $list ):
$inList = in_array($list->list_id, (array)#$this->listsByUser[$member->user_id]);
?>
<li class="<?php echo ( $inList !== false ? 'friend_list_joined' : 'friend_list_unjoined' ) ?> user_profile_friend_list_<?php echo $list->list_id ?>" onclick="handleFriendList(event, $(this), '<?php echo $member->user_id ?>', '<?php echo $list->list_id ?>');">
<span>
x
</span>
<div>
<?php echo $list->title ?>
</div>
</li>
<?php endforeach; ?>
<li>
<input type="text" title="<?php echo $this->translate('New list...') ?>" onclick="new Event(event).stop();" onkeypress="if( new Event(event).key == 'enter' ) { createFriendList(event, $(this), '<?php echo $member->user_id ?>'); }" />
</li>
</ul>
</div>
</div>
<?php echo $this->translate('add to list') ?>
</span>
</div>
<?php endif; // END LIST CODE ?>
</div>
<div class='profile_friends_options'>
<?php echo $this->userFriendship($member) ?>
</div>
</li>
and need to randomise the result..
I have tried using the
rand()
but that seem abortive.
Any help please