I would like the view the country list, state list and city list in the layout side menu in all the pages.
<div class="container side-menu">
<div class="row">
<div class="col-md-3">
<?php $countries = array();?>
<select class="form-control">
<option value="">All</option>
<?php foreach($countries as $country) { ?>
<?php echo "<option>".$country['name']."</option>"; ?>
<?php } ?>
</select>
</div>
<div class="col-md-3">
<?php $categories = array(); ?>
<select class="form-control">
<option value="">All</option>
<?php foreach($categories as $category) { ?>
<?php echo "<option>".$category['name']."</option>"; ?>
<?php } ?>
</select>
</div>
Related
Hi I want to use two methods of model in single foreach loop. but it get's me error........
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
I got error in view where I am using
PLO_weightage; ?>" min="1">
I have updated my question and add also methods of model
My Controller
public function assign_PLO($subj_session){
$data2 = array();
$data['data']=$this->portal->assign_subject_teacher_PLO($subj_session);
$data2['data2']=$this->PLO->PLO_detail();
$data2['data3'] = $this->portal->max_weightage_assign($subj_session);
$this->load->view('Teacher/Header');
$this->load->view('Teacher/PLO_subj_assign',$data+$data2);
$this->load->view('footer');
}
My view
<div class="col-md-12 text-center">
PLO Assign
<hr>
<div class="row" >
<?php
if($data3){
if($data2){
foreach($data2 as $tab){
?>
<div class=" col-md-4 text-left">
<div class="form-group alert alert-dark">
<div class="form-check">
<input class="form-check-input" value="<?php echo $tab->PLO_id;?>" name="assign_PLO[]" type="checkbox" id="gridCheck">
<label class="form-check-label" for="gridCheck" >
<?php echo $tab->PLO_name;?> </label>
<input class="form-control" type="number" name="assign_wt[]" max="<?php echo $data3->PLO_weightage; ?>" min="1">
</div>
</div>
</div>
<?php
}
}
}
?>
Model
public function PLO_detail(){
$query = $this->db->get('plo');
if($query->num_rows() >0){
return $query->result();
}else{
return false;
}
}
public function max_weightage_assign($subj_session){
$this->db->select_sum('PLO_weightage');
$this->db->select('PLO_weightage');
$this->db->where('session',$subj_session);
$this->db->group_by('PLO_id');
$query=$this->db->get('plo_data');
if($query->num_rows() >0){
return $query->result();
}else{
return false;
}
}
Having one html file called index.html.Here I'm having one page for list view(group).Another one(pg_add-group) is for both new and edit view.
If I hit the Add button from list view,the new form opened correctly.If I select any of the product from list view,its correctly uploaded the details to the edit view.
Its done by getting date from session.Now if I again try to add product, its containing old session data in the new form.The new form should contain with empty details.Can you help me to do this ?
Here is my coding,
pg_add-group
<div id="pg_add-group" data-role="page">
<form name="frm_add-group" id="frm_add-group" action="" method="post">
<div data-role="header" data-transition="fixed">
<h1 id="add-group-header"></h1>
Back
</div>
<div data-role="main" class="ui-content" >
<div id="add_sms-group_notification" class="center-wrapper-error" data-icon="right"></div>
<label for="group_name" class="ui-hidden-accessible"></label>
<input type="text" name="group_name" id="group_name" placeholder="Enter Group Name" />
<label for="group_desc" class="ui-hidden-accessible"></label>
<textarea name="group_desc" id="group_desc" placeholder="Enter Group Decription"></textarea>
<div class="containing-element">
<label for="group_published">Published</label>
<select name="group_published" id="group_published" data-theme="b">
<option value="1" >Yes</option>
<option value="0" >No</option>
</select>
<input type="hidden" name="group_id" id="group_id" />
</div>
<div class="containing-element">
<button type="submit" name="submit" value="submit" data-theme="a" data-icon="check">Submit</button>
<button type="reset" name="reset" value="reset" data-theme="a" data-icon="delete" >Reset</button>
</div>
<div data-role="footer" data-position="fixed">
<h1 id='add-book-footer'></h1>
</div>
</form>
</div>
test.js
From he below coding
group_id is comes from the list view's selected group id.
session data ses_group contains the list of groups.
$('#pg_add-group').on('pageshow', function(event) {
var group_list = $.parseJSON(sessionStorage.getItem("ses_group"));
var group_id = sessionStorage.group_id;
$.each(group_list, function(ctr, obj) {
if(group_id == obj.groupid){
$('input[id=group_name]').val(obj.groupname);
$('textarea[id=group_desc]').val(obj.groupdesc);
$('input[id=group_id]').val(obj.groupid);
$("#group_published").val('0').slider('refresh');
}
});
$( ".input[id=group_name]" ).textinput( "refresh" );
$( ".textarea[id=group_desc]" ).textinput( "refresh" );
});
Working example: http://jsfiddle.net/Gajotres/2AVWQ/
Usage:
Take a look at provided code, every element used has a custom attribute called data-default-value, it is used to determine which element is a default one. Basically use provided code to reset any form.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<!--<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>-->
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page" id="index" data-theme="a" >
<div data-role="header">
<h3>
First Page
</h3>
Next
</div>
<div data-role="content">
<input type="button" id="clr-form-btn" value="Clear form"/>
<label for="basic">Text Input:</label>
<input type="text" name="name" id="basic" value="Some value"/>
<label for="flip-1">Flip switch:</label>
<select name="flip-1" id="flip-1" data-role="slider" data-default-value="off">
<option value="off">Off</option>
<option value="on">On</option>
</select>
<fieldset data-role="controlgroup">
<legend>Choose a pet:</legend>
<input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1"/>
<label for="radio-choice-1">Cat</label>
<input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2" checked="checked" data-default-value=""/>
<label for="radio-choice-2">Dog</label>
<input type="radio" name="radio-choice" id="radio-choice-3" value="choice-3" />
<label for="radio-choice-3">Hamster</label>
<input type="radio" name="radio-choice" id="radio-choice-4" value="choice-4" />
<label for="radio-choice-4">Lizard</label>
</fieldset>
<label for="select-choice-0" class="select">Shipping method:</label>
<select name="select-choice-0" id="select-choice-0" data-default-value="standard">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
<textarea>
asd
asd
asd
as
das
d
asdassd
</textarea>
</div>
<div data-role="footer" data-position="fixed">
</div>
</div>
</body>
</html>
Javascript:
$(document).on('pagebeforeshow', '#index', function(){
cleanForm();
});
function cleanForm() {
var page = $.mobile.activePage;
// Reset input elements
page.find('.ui-content *').filter("[type='text'],textarea").each(function(){
$(this).val('');
});
// Reset drop down elements
page.find('.ui-content *').filter(".ui-select").each(function(){
var select = $(this).find('select');
var defaultValue = select.attr('data-default-value');
select.val(defaultValue);
select.selectmenu('refresh', true);
});
// Reset flip switch elements
page.find('.ui-content *').filter('[data-role="slider"]').each(function(){
var flipSwitch = $(this);
var defaultValue = flipSwitch.attr('data-default-value');
flipSwitch.val(defaultValue);
flipSwitch.slider('refresh');
});
// Reset radio elements
page.find('.ui-content *').filter('fieldset:has([type="radio"])').each(function(){
var radio = $(this);
var checkedRadio = radio.find(':checked').prop("checked",false).checkboxradio("refresh");
var defaultRadio = radio.find('[data-default-value]').prop("checked",true).checkboxradio("refresh");
});
}
Sir
this a part of our mini project and the code use to work well without the option to upload an image.Here we are having a folder "missingCaseImage" inorder to stre the uploaded image. But this code shows that the image already exist while pressing procced button
<!DOCTYPE html PUBLIC >
<?php
include("connection.php");
session_start();
if(isset($_POST['proceed']))
{
$ctype=$_POST['id13'];
$email=$_POST['email'];
if($ctype=='Missing'){
$MCImage=$_FILES['missingImage']["name"];
if (file_exists("../missingCaseImage/" . $MCImage))
{
?>
<script>
alert('Image Name already exists');
window.location.href='dem.php';
</script>
<?php
exit;
}
else
{
move_uploaded_file($_FILES["missingImage"]["tmp_name"],"../missingCaseImage/" .
$_FILES["missingImage"]["name"]);
}
}
$insert="insert into cregister(e_mail,image,cs_type,) values('$email','$MCImage')";
mysql_query($insert);
$lastid = mysql_insert_id();
$_SESSION['cno']=$lastid;
header("location:printform.php");
}
?>
<html >
<?php
if(isset($_GET['error'])){$error=$_GET['error'];} else{$error="";} // if error happaning echo this $error msg
?>
<fieldset>
<form id="form1" name="form1" method="post" action="">
<h3>CASE REGISTRATION FORM</h3>
<P>
<label for="id1">EMAIL ID</label>
<input name="email" type="email" class="validate[required,custom[email]]" id="email" value="<?php echo $_SESSION['email'];?>"
readonly/>
<br />
<P>
<label for="id1">CASE TYPE</label>
<select name="id13" class="validate[required]" id="id13" onChange="missingCase(this.value)">
<option>Murder</option>
<option>Robbery</option>
<option>Vehicle</option>
<option>Missing</option>
<option>Others</option>
</select>
<br />
<P style="display:none;" id="missingImageP" >
<label for="missingImage">UPLOAD IMAGE</label>
<input type="file" name="missingImage" class="uploadMC"/>
<p>
<input name="proceed" type="submit" id="proceed" value="PROCEED"? />
<p>
</form>
</fieldset>
</html>
<script>
function missingCase(mc){
//alert(mc);
if(mc=='Missing'){
$('#missingImageP').show();
}
else{
$('#missingImageP').hide();
}
}
</script>
So now the problem is whenever i try to upload a photo and click on proceed button it always displays Image Name already exists... Why is that so how can i rectify it
NOte: All the required script for validation were been included ..
Thankyou in advance...
I want to group the form fields like field set or simply enclosed by div. My form needs to be look like below
<form>
<div class="step-1">
Field 1
Field 2
</div>
<div class="step-2">
Field 3
Field 4
</div>
</form>
Graphical example :
Edit : Form class added for reference!
class ProfileForm extends BaseProfileForm
{
public function configure()
{
..... // other widget configuration
$this->embedForm('media', new MediaForm());
}
}
How can I do this in symfony form?
For example:
In action:
$this->form = new MyCoolForm()
In templates:
<form name="form name" id="MyCoolForm" action="<?php echo url_for('action_url') ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php echo $form['name']->render() ?>
<?php echo $form['name']->renderError(); ?>
<fieldset>
<legend>Ppassword:</legend>
<?php echo $form['password']->render() ?>
<?php echo $form['password']->renderError(); ?>
<?php echo $form['password_again']->render() ?>
<?php echo $form['password_again']->renderError(); ?>
<fieldset>
<?php echo $form->renderHiddenFields(); ?>
</form>
etc...
this is the index action and template generated at the backend for the
model "coche".
public function executeIndex(sfWebRequest $request)
{
// sorting
if ($request->getParameter('sort') &&
$this->isValidSortColumn($request->getParameter('sort')))
{
$this->setSort(array($request->getParameter('sort'),
$request->getParameter('sort_type')));
}
// pager
if ($request->getParameter('page'))
{
$this->setPage($request->getParameter('page'));
}
$this->pager = $this->getPager();
$this->sort = $this->getSort();
}
This is the index template:
<?php use_helper('I18N', 'Date') ?>
<?php include_partial('coche/assets') ?>
<div id="sf_admin_container">
<h1><?php echo __('Coche List', array(), 'messages') ?></h1>
<?php include_partial('coche/flashes') ?>
<div id="sf_admin_header">
<?php include_partial('coche/list_header', array('pager' => $pager)) ?>
</div>
<div id="sf_admin_bar">
<?php include_partial('coche/filters', array('form' => $filters,
'configuration' => $configuration)) ?>
</div>
<div id="sf_admin_content">
<form action="<?php echo url_for('coche_coche_collection',
array('action' => 'batch')) ?>" method="post">
<?php include_partial('coche/list', array('pager' => $pager, 'sort' =>
$sort, 'helper' => $helper)) ?>
<ul class="sf_admin_actions">
<?php include_partial('coche/list_batch_actions', array('helper' =>
$helper)) ?>
<?php include_partial('coche/list_actions', array('helper' => $helper)) ?>
</ul>
</form>
</div>
<div id="sf_admin_footer">
<?php include_partial('coche/list_footer', array('pager' => $pager)) ?>
</div>
</div>
In the template there is this line:
include_partial('coche/filters', array('form' => $filters,
'configuration' => $configuration)) ?>
but i can not find the variables $this->filters and $this->configuration in the
index action.
How is that possible?
Javi
Is the index action extending a class? If yes, that's how!
It looks like a module generated by admin generator. If it's so, then these vars are set in autoCocheActions class which resides in project cache and is generated on the fly.