Yii Radio Buttons - php

I am using radio buttons in Yii and no matter what I do I can't get the value of the selected button to post. I am sure its just something simple. I am NOT using radioButtonList because I want each button to exist in its own div with an image above it.
Here is my code from the view...
<?php $this->pageTitle=Yii::app()->name; ?>
<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'lead_form',
'enableAjaxValidation'=>false,
)); ?>
<h3>Choose Your Prize!</h3>
<div id="prizes">
<div class="prize">
<h3>Paypal</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>1)); ?>
</div>
<div class="prize">
<h3>Check</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>2)); ?>
</div>
<div class="prize">
<h3>AlertPay</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>3)); ?>
</div>
<div class="prize">
<h3>Iphone 4</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>4)); ?>
</div>
<div class="prize">
<h3>Ipad 2</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>5)); ?>
</div>
<div class="prize">
<h3>Custom</h3>
<?php echo $form->radioButton($model,'user_prize',array('value'=>6)); ?>
</div>
</div>
<h3>Enter Your Email</h3>
<div id="mainemail">
<div class="row">
<?php echo $form->labelEx($model,'user_email'); ?>
<?php echo $form->textField($model,'user_emhttp://stackoverflow.com/editing- helpail'); ?>
<?php echo $form->error($model,'user_email'); ?>
</div>
<div>
<?php echo $form->errorSummary($model); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
endWidget(); ?>

<?php echo $form->radioButton($model,'user_prize',array('value'=>1,'uncheckValue'=>null)); ?>
<?php echo $form->radioButton($model,'user_prize',array('value'=>2,'uncheckValue'=>null)); ?>
<?php echo $form->radioButton($model,'user_prize',array('value'=>3,'uncheckValue'=>null)); ?>
<?php echo $form->radioButton($model,'user_prize',array('value'=>4,'uncheckValue'=>null)); ?>
<?php echo $form->radioButton($model,'user_prize',array('value'=>5,'uncheckValue'=>null)); ?>
just add
'uncheckValue'=>null
in htmlOption array
it will work..

In CHtml::activeRadioButtonList's third parameter (htmlOptions) there is an option called 'template'. You should take a look.

Related

Image height not working on php loop

Here's the div that manages the look of each item in the loop:
<div style="float:left;width:30%;padding:30px;height:auto;">
<img src="<?php echo $r['image']['sizes']['team']; ?>" style="max-width:750px !important;width:100%;">
<h3>
<?php echo $r['name']; ?>
</h3>
<div class="position">
<?php echo $r['position']; ?>
</div>
<?php echo $r['intro_text']; ?>
<?php if ($r['learn_more_text']) { ?>
Learn More
<?php } ?>
<?php if ($r['learn_more_text']) { ?>
<div id="<?php echo sanitize_title($r['name']); ?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<h3><?php echo $r['name']; ?></h3>
<div class="position">
<?php echo $r['position']; ?>
</div>
<div class="content">
<?php echo $r['learn_more_text']; ?>
</div>
<a class="close-reveal-modal" aria-label="Close">×</a>
</div>
</div>
If I set the height to a fixed number (eg: 450x), the images are aligned in a row. But that will make the page non mobile responsive. If I set the height to auto or to a percentage like 30%, the images become mobile responsive but they don't align. I get 2 images that separate into different rows.
Also, I got 2 sections of image. One is called Our Leadership and the other is called Our Team. The section at the bottom is aligned correctly and is contained in a div. The div above it refuses to be contained in a div. If I wrap it in a div, Only the first item wraps itself in the div. I've no idea why.
eg:
<center>
<div>
<div>first item here</div>
</div>
<div>second item here</div>
<div>third item here</div>
<div>fourth item here</div>
Here's the complete code for both sections:
<center><h2>Our Leadership</h2></center>
<center><div>
<?php
$people = get_field('people');
$a = 0;
foreach ($people as $r) {
$a++;
?>
<div style="float:left;width:30%;padding:30px;height:auto;">
<img src="<?php echo $r['image']['sizes']['team']; ?>" style="max-width:750px !important;width:100%;">
<h3>
<?php echo $r['name']; ?>
</h3>
<div class="position">
<?php echo $r['position']; ?>
</div>
<?php echo $r['intro_text']; ?>
<?php if ($r['learn_more_text']) { ?>
Learn More
<?php } ?>
<?php if ($r['learn_more_text']) { ?>
<div id="<?php echo sanitize_title($r['name']); ?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<h3><?php echo $r['name']; ?></h3>
<div class="position">
<?php echo $r['position']; ?>
</div>
<div class="content">
<?php echo $r['learn_more_text']; ?>
</div>
<a class="close-reveal-modal" aria-label="Close">×</a>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div></center>
<div style="clear:both;"></div>
<center><h2>Our Team</h2></center>
<center><div>
<?php
$people2 = get_field('people_bottomsection');
$a = 0;
foreach ($people2 as $r) {
$a++;
?>
<div style="float:left;width:30%;padding:30px;height:auto;">
<img src="<?php echo $r['image']['sizes']['team']; ?>" style="max-width:750px !important;width:100%;">
<h3>
<?php echo $r['name']; ?>
</h3>
<div class="position">
<?php echo $r['position']; ?>
</div>
<?php echo $r['intro_text']; ?>
<?php if ($r['learn_more_text']) { ?>
Learn More
<?php } ?>
<?php if ($r['learn_more_text']) { ?>
<div id="<?php echo sanitize_title($r['name']); ?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<h3><?php echo $r['name']; ?></h3>
<div class="position">
<?php echo $r['position']; ?>
</div>
<div class="content">
<?php echo $r['learn_more_text']; ?>
</div>
<a class="close-reveal-modal" aria-label="Close">×</a>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div></center>
<div style="clear:both;"></div>
Check out the source code at: http://www.equitasmg.com/who-we-are-2/
it's because the items in the loop are having different height. So, try adding a constant height to each item in the loop.
Eg:
<div style="float:left;width:30%;padding:30px;min-height:550px;"></div>

not able to call a codeigniter function using form_open

In codeigniter currently I am working on shopping cart but the problem is I am not able to call a function using form_open in codeigniter.
However, in the same project in another place same code is working properly but in other view form_open it's not working.
Here is my code:
<?php if(count($data)):?>
<?php foreach($data as $head_data) :?>
<div class="row">
<?php echo form_open('Shopingcart/add',['class'=>'form-horizontal']);?>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="imagebox">
<img src=<?php echo base_url($head_data->p_image)?> class="" alt="picture">
<h2>New This Week</h2>
<p>Browse New Portraits and Abstracts</p>
<p id="id"><?= $head_data->p_id ?></p>
<p id="p_price"><?= $head_data->p_price ?></p>
<p id="p_name"><?= $head_data->p_name ?></p>
<?= anchor('Stuff','View Collections',['class'=>'btn btn-primary'])?>
<?php
echo form_hidden('id', $head_data->p_id);
echo form_hidden('qty', 1);
echo form_hidden('name', $head_data->p_name);
echo form_hidden('price', $head_data->p_price);
?>
<p><?php echo form_submit('', 'Add to Cart'); ?></p>
<?php echo form_close(); ?>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<p> No content found</p>
<?php endif ?>
check to see if you are loading the helper.
$this->load->helper('form');
somewhere in your code. preferably in the constructor.
also make sure that error notifications are are turned on, these sorts of problems should give errors that help.
change your code with below one
<?php if(count($data)):?>
<?php foreach($data as $head_data) :?>
<div class="row">
<?php echo form_open('Shopingcart/add',array('class'=>'form-horizontal'));?>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="imagebox">
<img src=<?php echo base_url($head_data->p_image)?> class="" alt="picture">
<h2>New This Week</h2>
<p>Browse New Portraits and Abstracts</p>
<p id="id"><?= $head_data->p_id ?></p>
<p id="p_price"><?= $head_data->p_price ?></p>
<p id="p_name"><?= $head_data->p_name ?></p>
<?= anchor('Stuff','View Collections',array('class'=>'btn btn-primary'))?>
<?php
echo form_hidden('id', $head_data->p_id);
echo form_hidden('qty', 1);
echo form_hidden('name', $head_data->p_name);
echo form_hidden('price', $head_data->p_price);
?>
<p><?php echo form_submit('', 'Add to Cart'); ?></p>
</div>
</div>
<?php echo form_close(); ?>
<?php endforeach; ?>
<?php else: ?>
<p> No content found</p>
<?php endif ?>

Make image as a link in Codeigniter

I am trying to make image as a link in Codeigniter but <a> tag is not working. I am trying to make image as a link but inside foreach loop <a> tag is not working.
Here is my code
<?php if(count($trendpost)):?>
<?php if(count($trendpost)<=3):?>
<div class="row">
<?php foreach($trendpost as $post): ?>
<div class="col-lg-4 col-md-4">
<a href=<?php echo site_url($post->url)?>> <img class="imageborder trendimg" src=<?php echo site_url($post->link)?>></a>
<p><?= $post->news ?></p>
</div>
<?php endforeach; ?>
</div>
<?php else: ?>
<div class="row">
<?php foreach($trendpost as $post) :?>
<div class="col-lg-4 col-md-4">
<img class="imageborder trendimg" src=<?php echo site_url($post->link)?>>
<p><?= $post->news ?></p>
</div>
<?php endforeach; ?>
</div>
<?php endif ?>
<?php else: ?>
<p> not found</p>
<?php endif ?>
</div>
</div>
change your code to this and please check again.
<?php if(count($trendpost)):?>
<?php if(count($trendpost)<=3):?>
<div class="row">
<?php foreach($trendpost as $post): ?>
<div class="col-lg-4 col-md-4">
<img class="imageborder trendimg" src=<?php echo site_url($post->link)?>>
<p><?= $post->news ?></p>
</div>
<?php endforeach; ?>
</div>
<?php else: ?>
<div class="row">
<?php foreach($trendpost as $post) :?>
<div class="col-lg-4 col-md-4">
<a href="<?php echo site_url($post->url)?>" style="display: block;">
<img class="imageborder trendimg" src=<?php echo site_url($post->link)?>></a>
<p><?= $post->news ?></p>
</div>
<?php endforeach; ?>
</div>
<?php endif ?>
<?php else: ?>
<p> not found</p>
<?php endif ?>
You can use
<?php echo anchor('your Controller_name/link','<img src="your path" /> ','class="btn btn-default btn-flat"')?>
instead of anchor Tag

Search results form to show another page

I am using a Vebra plugin on Wordpress, they use shortcodes to show a search area and a shortcode to show the results.
I have my homepage (http://lytham.voodoodev4.co.uk/) using the "search" shortcode, my "properties" shortcode is on http://lytham.voodoodev4.co.uk/?page_id=33
When I search on the page it just refreshes the page, how do I push the search results to that page?
Search php:
<div id="propertyFilter" class="vp_search">
<form action="<?php echo vp_get_search_link()?>" method="GET">
<?php vp_hidden_fields(); ?>
<div class="property_refine">Refine your search:</div>
<div class="property_type">
<?php vp_get_areas(); ?>
</div>
<div class="property_search_group">
<p>Minimum number of bedrooms</p>
<?php vp_get_bedrooms(); ?>
</div>
<div class="property_search_group vp_price">
<p>Minimum price of property</p>
<?php vp_get_minprice(); ?>
</div>
<div class="property_search_group vp_price">
<p>Maximum price of property</p>
<?php vp_get_maxprice(); ?>
</div>
<div class="property_search_group vp_rent">
<p>Minimum rent for property</p>
<?php vp_get_minrent(); ?>
</div>
<div class="property_search_group vp_rent">
<p>Maximum rent for property</p>
<?php vp_get_maxrent(); ?>
</div>
<div class="property_search_group vp_commercial">
<p>Min Area (sqft)</p>
<?php vp_get_minarea(); ?>
</div>
<div class="property_search_group vp_commercial">
<p>Max Area (sqft)</p>
<?php vp_get_maxarea(); ?>
</div>
<div class="property_search_group">
<p>Type of property</p>
<?php vp_get_property_types(); ?>
</div>
<div class="property_search_group">
<p>Location</p>
<input type="text" id="vp_location" name="vp_location" placeholder="Enter postcode or place name" value="<?php vp_get_location(); ?>" />
</div>
<div class="property_search_group">
<p>Search</p>
<?php vp_get_radius(); ?>
</div>
<input class="submit" type="submit" value="Search" />
</form>
</div>
Properties results PHP:
<div id="propertyResults">
<?php echo vp_list_head();
if ($properties=vp_theproperties()) {
switch (vp_get_view()) {
case "list": ?>
<div id="propertyListView">
<div id="propertyOrdering" class="clearfix">
<div id="orderBy">
<span id="vp_order_message">Order by:</span>
<?php vp_get_orderby(); ?>
View Map
</div>
</div>
<div class="clearfix">
<?php foreach ($properties as $property) { ?>
<div class="property">
<div class="left_column">
<div class="property_image">
<a class="property_overview_thumb" href="<?php echo vp_propertyurl($property->vebraid); ?>" title="<?php echo $property->address_custom; ?>">
<?php echo vp_propertyimage($property->vebraid,0,"property_image"); ?>
</a>
<div class="property_tagline"><?php echo $property->web_status; ?></div>
</div>
</div>
<div class="right_column">
<div class="property_summary">
<h3 class="property_title">
<span><?php echo $property->address_custom; ?> <?php echo $property->property_type; ?></span>
</h3>
<h4 class="property_address"><?php echo $property->address_display; ?></h4>
<div class="property_excerpt"><?php echo $property->excerpt; ?></div>
</div>
</div>
<div class="property_features clearfix">
<?php if ($property->area == "Commercial") {
if (!empty($property->propertyarea_sqft)) {?>
<span class="property_area"><?php echo $property->propertyarea_sqft; ?> sqft</span>
<?php } ?>
<?php } else {?>
<span class="property_beds"><?php echo $property->bedrooms; ?> Bedrooms</span>
<span class="property_baths"><?php echo $property->bathrooms; ?> Bathrooms</span>
<?php } ?>
<div class="property_price">£<?php echo number_format($property->price,0,"",","); ?> <?php echo $property->price_postfix; ?>View Details<?php do_action('vp_other_action_buttons',$property->vebraid,'button property_button') ?></div>
</div>
</div>
<?php } ?>
</div>
<div class="properties-paging">
<ul>
<?php if (vp_current_page() > 1) { ?>
<li>< Previous</li>
<?php } ?>
<li>Page <?php echo vp_current_page(); ?> of <?php echo vp_page_count(); ?></li>
<?php if (vp_current_page() < vp_page_count()) { ?>
<li>> Next</li>
<?php } ?>
</ul>
</div>
</div>
<?php
break;
case "map":?>
<div id="propertyMapView">
<div id="propertyOrdering" class="clearfix">
<div id="orderBy">
View List
</div>
</div>
<?php vp_map_markers($properties); ?>
<div id="vp-map" style="width: 100%; height: 550px;"></div>
</div>
<?php
break;
case "featured": ?>
<?php foreach ($properties as $property) { ?>
<div class="property">
<div class="left_column">
<div class="property_tagline badge_<?php echo str_replace(" ","_",$property->web_status); ?>"></div>
<div class="property_image">
<a class="property_overview_thumb" href="<?php echo vp_propertyurl($property->vebraid); ?>" title="<?php echo $property->address_name; ?>">
<?php echo vp_propertyimage($property->vebraid,0,"property_image"); ?>
</a>
</div>
</div>
<div class="right_column">
<ul class="property_summary">
<li class="property_title">
<?php echo $property->address_custom; ?><span><?php echo $property->property_type; ?></span>
</li>
<li class="property_address"><?php echo $property->address_display; ?></li>
<li class="property_price">£<?php echo number_format($property->price,0,"",","); ?> <?php echo $property->price_postfix; ?></li>
</ul>
<div class="buttons clearfix">
View Details
</div>
</div>
</div>
<?php } ?>
<?php
break;
}
} else { ?>
<p>No matching properties found. Please try alternative search criteria.</p>
<?php } ?>
<?php echo vp_list_footer();?>
</div>
SOLVED:
In the vp-search.php I changed:
<form action="<?php echo vp_get_search_link()?>" method="GET">
to
<form action="<?php echo vp_get_search_link()?>/property-results/" method="GET">
Obviously replace /property-results/ for the page that has the properties shortcode in it :)

PHP affecting column layout

The structure of the main body of my page is constructed of three columns, these columns are generated by MYSQL data and then formulated in to three columns using PHP.
Below is PHP code and the layout which provides the three columns. The problem which I have is that if the data provides a layout two columns wide then everything is fine and it looks like this.
http://goo.gl/TDKI2J
However if the data provides a layout three columns wide then it looks like this.
http://goo.gl/0uqPvX
I think the problem is the div tag after the on the third column, but not sure of the best way to fix the issue.
Here is the code.
<?php $columnSelector = 0; // define a column selector ?>
<?php while($row = mysql_fetch_array($result)) :?>
<?php if ($columnSelector == 0): ?>
<div class="row-fluid">
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> | </p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<?php elseif ($columnSelector == 1): ?>
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
<?php elseif ($columnSelector == 2): ?>
<article class="span4 mid">
<div class="img">
<img src="images/<?php echo $row['image_link']; ?>" alt="post4" />
<div class="overlay"></div>
</div>
<div class="info">
<p class="tags">
<?php echo $row['event_type']; ?>
<?php echo $row['location']; ?>
</p>
<h1><?php echo $row['event_title']; ?></h1>
<p class="details"> <?php echo $row['date']; ?> | <?php echo $row['posted_by']; ?></p>
<p class="text">
<?php echo $row['event_details_short']; ?>
</p>
</div>
</article>
</div>
<?php endif; ?>
<?php $columnSelector++; // advance to the next row?>
<?php $columnSelector %= 3; // reset to zero every third event?>
<?php endwhile; ?>
It is probably the if statement don't let the code below to shown.
This line : <?php if ($columnSelector == 0): ?>
OK, solved it, the problem was the last tag here:
</article>
</div>
It was needed for when only one or two columns show but not for the third and so i replaced it with this.
</div>
</article>
<?php if ($columnSelector == 1){ ?>
</div>
<?php } ?>
<?php endif; ?>
And so now when there is three columns the div doesn't show and the layout is correct.

Categories