I need to use collections to make dynamic inputs, but needed to pull out the individual elements to integrate them into a Bootstrap layout.
Unfortunately I can't find any documented way of doing this.
Could someone help-me?
Here is my form: http://pastebin.com/JGy7JEJk Fieldset used in form:
http://pastebin.com/VBbG1yyb
Form HTML: http://pastebin.com/HHaZZKsB
Form View Helper: http://pastebin.com/x7B9aPWG
You can see this in action http://protesto21.com.br/cadastro/encargo-vigencia/atualizar/2/
User admin, password p21
Thanks for all and sorry for my english
Problem solved
public function renderCollection($element)
{
$return = '';
if (count($element->getMessages()) > 0) {
$return .= '<div class="form-group has-error">';
} else {
$return .= '<div class="form-group">';
}
foreach ($element->getIterator() as $field) {
$label = ($this->isView) ? '<strong>' . $element->getLabel() . '</strong>' : $element->getLabel();
$return .= '<label class="col-md-3 control-label">' . $label . '</label>';
$return .= '<div class="col-md-8" style="margin-bottom: 20px;">';
foreach ($field->getElements() as $inputs) {
$return .= '<div style="float: left; margin-right: 20px;">';
$return .= $inputs->getLabel();
$return .= $this->renderInput($inputs);
$return .= '<div style="min-width: 265px;">';
foreach ($inputs->getMessages() as $mensagem) {
$return .= "<span class='help-block'>" . $mensagem . "</span>";
}
$return .= '</div>';
$return .= '</div>';
}
$return .= '</div>';
$element->setLabel('');
}
$return .= '</div>';
return $return;
}
Related
I have a problem for making TAB dynamically. When I click Tab 2 (when class="tab-pane fade"), a tab content was duplicated from Tab 1 and so do to another tab.This is a screenshot
And this is my php code :
$sql1 = "SELECT * FROM pur_supp WHERE pn = '$id_p' and pn_interchange = '$id_a'";
$hasil1= mysqli_query($connect2,$sql1);
//$rowp = mysqli_fetch_assoc($hasil1);
$tab_menu = '';
$tab_content = '';
$i = 0;
while($row1 = mysqli_fetch_array($hasil1))
{
if($i == 0)
{
$tab_menu .= '
<li class="active">Priority '.$row1["priority"].'</li>
';
$tab_content .= '
<div id="priority'.$row1["priority"].'" class="tab-pane fade in active">
';
}
else
{
$tab_menu .= '
<li>Priority '.$row1["priority"].'</li>
';
$tab_content .= '
<div id="priority'.$row1["priority"].'" class="tab-pane fade">
';
}
$sql2 = "SELECT * FROM pur_supp WHERE pn = '$id_p' and pn_interchange = '$id_a' and priority = '".$row1["priority"]."' GROUP BY pn,pn_interchange";
$hasil2= mysqli_query($connect2,$sql2);
while($rowp = mysqli_fetch_array($hasil2))
{
$tab_content .= '<div class="panel-heading" align="center">';
$tab_content .= '<h2 >Selected Vendor Information</h2>';
$tab_content .= '<div class="panel-heading" align="center">';
$tab_content .= '<h5 >PURCHASE SUPPLIER</h5>';
$tab_content .= '<p style="font-weight: bold">Part Number';
$tab_content .= '<input style="text-align:center;margin-left: 90px" class="form-control" type="text" name="pn1" value="'. $rowp['pn'].'" readonly> </p>';
$tab_content .= ' <p style="font-weight: bold; text-align: left">Selected Vendor Information : Priority '.$rowp['priority'].'</p>';
}
$i++;
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
How do you place a foreach loop inside a tag?
here's the code:
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail( $designer_post->ID, "thumbnail" );
$html .= '<tr>';
$html .= '<th scope="row">View</th>';
$html .= '<td><p>'.$designer_post->post_title.'</p></td>';
$html .= '<td>'FOREACH LOOP HERE!!!'</td>';
$html .= '<td>'.$imageThumb.'</td>';
$html .= '</tr>';
}
I keep getting an error. Could you help me with the PROPER syntax?
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail( $designer_post->ID, "thumbnail" );
$html .= '<tr>';
$html .= '<th scope="row">View</th>';
$html .= '<td><p>'.$designer_post->post_title.'</p></td>';
$html .= '<td>';
foreach() {
$html .= 'The rest of the HTML code';
}
$html .= '</td>';
$html .= '<td>'.$imageThumb.'</td>';
$html .= '</tr>';
}
I think you want to do this :
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail( $designer_post->ID, "thumbnail" );
$html .= '<tr>';
$html .= '<th scope="row">View</th>';
$html .= '<td><p>'.$designer_post->post_title.'</p></td>';
$html .= '<td>';
foreach($designer_post as $test) {
$html .= 'what you want fraté';
}
$html .= '</td>';
$html .= '<td>'.$imageThumb.'</td>';
$html .= '</tr>';
}
<?php
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail($designer_post->ID,"thumbnail");
?>
<tr>
<th scope="row">View</th>
<td><p> <?php print $designer_post->post_title; ?></p></td>
<td>
<?php foreach($array_data as $data) {
print $data;
} ?>
</td>
<td> <?php print $imageThumb; ?></td>
</tr>
<?php } ?>
Ok i have one query in codeigniter where i select all data
function get_story()
{
$this->db->select('*');
$this->db->from('stories');
$query = $this->db->get();
return $query;
}
then i make another query with data from another table
function get_stories()
{
$this->db->from('stories');
$this->db->join('stories_to_categories', 'stories.id = stories_to_categories.story');
$this->db->join('categories', 'stories_to_categories.category = categories.id');
$query = $this->db->get();
return $query;
}
Then i am trying to create table with data from two queries. Making one query with another JOIN its not option. I created foreach
foreach($story->result() as $row)
{
echo '<tr>
<td>'.$row->title_english.'</td>
<td>'?????????????????????????????????????????????????????</td>
<td align="center">
<img src="'.site_url('admin/images/icons/pencil.png').'" class="tooltip" title="'.lang('edit').'" />
<img src="'.site_url('admin/images/icons/minus-circle.png').'" class="tooltip" title="'.lang('delete').'" />
</td>
</tr>
';
echo '<div id="delete_'.$row->id.'" style="display: none;">
<h1>'.lang('client_delete').'</h1><br />
'.lang('story_confirm_delete').'
<br /><br />
<span><span>'.lang('yes').'</span></span>
<span><span>'.lang('no').'</span></span>
<br /><br />
</div>';
}
In td tag where is ???? i need results from second query, i have no idea how to insert data from second query into foreach??? Does somebody have idea, helpe is really needed?
If I understand your question, I think you just need to use string concatenation. Prepare your HTML output into a variable and print it later.
$html = '<table>';
foreach($story->result() as $row)
{
$html .= '<tr>';
$html .= '<td>'.$row->title_english.'</td>';
$html .= '<td>';
foreach($stories->result() as $row2){
// display your second query result here
$html .= '?????????????????????????????????????????????????????';
}
$html .= '</td>';
$html .= '<td align="center">';
$html .= '<img src="'.site_url('admin/images/icons/pencil.png').'" class="tooltip" title="'.lang('edit').'" />';
$html .= '<img src="'.site_url('admin/images/icons/minus-circle.png').'" class="tooltip" title="'.lang('delete').'" />';
$html .= '</td>';
$html .= '</tr>';
$html .= '<div id="delete_'.$row->id.'" style="display: none;">';
$html .= '<h1>'.lang('client_delete').'</h1><br />';
$html .= lang('story_confirm_delete');
$html .= '<br /><br />';
$html .= '<span><span>'.lang('yes').'</span></span>';
$html .= '<span><span>'.lang('no').'</span></span>';
$html .= '<br /><br />';
$html .= '</div>';
}
$html .= '</table>';
echo $html;
I am using Wordpress.
CSS:
fsrep-main-image {
float: left;
margin-right: 8px;
text-align: center;
overflow: hidden
}
fsrep-main-image img {
padding: 1px;
border: 1px solid #CCC;
float:left;
overflow:hidden
}
description {
display:-block;
margin-top:-150px
}
When I open the page in Firefox it works fine, however if I open the same page in Chrome it has issues.
The following image is from Firefox, but in Chrome the description, location and bedroom details goes on the image.
HTML/PHP:
<?php
$PageContent = '<hr/>';
$WPUploadDir = wp_upload_dir();
$FSREPShowMap = $FSREPconfig['GoogleMap'];
if (isset($FSREPMap)) {
if ($FSREPMap == FALSE) {
$FSREPShowMap = FALSE;
}
}
$ListingDetails = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."fsrep_listings WHERE listing_id = ".$ListingID[0]);
if ($ListingDetails->listing_address_number == '' || $ListingDetails->listing_address_street == '' || $ListingDetails->listing_address_city == '') { $FSREPShowMap = FALSE; }
if ($FSREPconfig['DisplayCurrency'] == 'Yes') { $CurrencyDisplay = ' '.$FSREPconfig['CurrencyType']; } else { $CurrencyDisplay = ''; }
$PageContent .= '<h1>'.fsrep_listing_name_gen($ListingDetails->listing_id, $FSREPconfig['ListingNameDisplay']).'</h1>';
if ($ListingDetails->listing_price_num != '0.00') { $PageContent .= '<span class="listingprice">'; if ($FSREPconfig['ListingPriceID'] != '') { $PageContent .= fsrep_text_translator('FireStorm Real Estate Plugin', $FSREPconfig['ListingPriceID'].' Label', $FSREPconfig['ListingPriceID']).' '; } $PageContent .= $FSREPconfig['Currency'].fsrep_currency_format($ListingDetails->listing_price_num).$CurrencyDisplay.'</span><br />'; }
$PageContent .= '';
$FSREPImageSizes = fsrep_image_sizes();
$FSREPMainImageMargin = $FSREPImageSizes->main[0] + 4;
$FSREPImageMargin = $FSREPImageSizes->main[0] + 2;
$PageContent .='<div id="vertical_menu" style="float:right">
<a onclick=show_desc()>Overview</a>
<hr/>
<a onclick=show_Location()>Location Map</a>
<hr/>
<a onclick=show_enquiry()>Enquiry</a>
</div>';
$PageContent .= '<div id="fsrep-images" style="display:block">';
if (file_exists($WPUploadDir['basedir'].'/fsrep/houses/large/'.$ListingDetails->listing_id.'.jpg')) {
$PageContent .= '<div id="fsrep-main-image" style="width: '.$FSREPMainImageMargin.'px;display:block"><a id="fsrep-main-image-a" href="'.$WPUploadDir['baseurl'].'/fsrep/houses/large/'.$ListingDetails->listing_id.'.jpg" title="View Slideshow" class="thickbox" rel="fsreplisting"><img id="fsrep-main-image-img" src="'.$WPUploadDir['baseurl'].'/fsrep/houses/'.$ListingDetails->listing_id.'.jpg" alt="'.strip_tags(fsrep_listing_name_gen($ListingDetails->listing_id, $FSREPconfig['ListingNameDisplay'])).'" /></a></div>';
}
$PageContent .= '<div id="fsrep-aimages" style="margin-left: '.$FSREPImageMargin.'px; display:block">';
for ($i=1;$i<=50;$i++) {
if (file_exists($WPUploadDir['basedir'].'/fsrep/houses/additional/small/'.$ListingDetails->listing_id.'-'.$i.'.jpg')) {
//$PageContent .= '<div class="fsrep-aimage" id="fsrep-aimage" style="display:block"><img src="'.$WPUploadDir['baseurl'].'/fsrep/houses/additional/small/'.$ListingDetails->listing_id.'-'.$i.'.jpg" class="full" /></div>';
}
}
$PageContent .= '</div>';
if (file_exists($WPUploadDir['basedir'].'/fsrep/houses/large/'.$ListingDetails->listing_id.'.jpg')) {
//$PageContent .= '<div class="fsrep-aimage" id="fsrep-aimage" style="display:block"><img src="'.$WPUploadDir['baseurl'].'/fsrep/houses/small/'.$ListingDetails->listing_id.'.jpg" class="full" /></div>';
}
$PageContent .= '</div>';
$PageContent .= '<div style="clear: both;"></div>';
if ($FSREPShowMap == TRUE) {
$PageContent .= '<div id="location_map" style="display:none;float:left;width:920px">
<div style="margin-top:-150px;width: 80%;"><h2>'.fsrep_text_translator('FireStorm Real Estate Plugin', 'Located in Label', 'Located in').' '.fsrep_get_address_name($ListingDetails->listing_address_city, 'city').', '.fsrep_get_address_name($ListingDetails->listing_address_province, 'province').'</h2>';
// $PageContent .= '<div class="fsrep-aimager">Map</div>';
$PageContent .= '<div id="listings_map" style="width: 80%; height: 400px; border: 1px solid #999999; margin-bottom: 12px;"></div></div></div>';
$PageContent .= '<br />';
}
/*
$AdditionalImages = '';
for ($i=1;$i<=10;$i++) {
if (file_exists($WPUploadDir['basedir'].'/fsrep/houses/additional/small/'.$ListingDetails->listing_id.'-'.$i.'.jpg')) {
$AdditionalImages .= '<td align="center" valign="center"><img src="'.$WPUploadDir['baseurl'].'/fsrep/houses/additional/small/'.$ListingDetails->listing_id.'-'.$i.'.jpg" class="full" /></td>';
if ($i == 4) {
$AdditionalImages .= '</tr><tr>';
}
}
}
if ($AdditionalImages != '') {
$PageContent .= '<h2>Photo Gallery</h2>';
$PageContent .= '<table><tr><td><img src="'.$WPUploadDir['baseurl'].'/fsrep/houses/small/'.$ListingDetails->listing_id.'.jpg" class="full" /></td>'.$AdditionalImages.'</tr></table>';
$PageContent .= '<p> </p>';
}
*/
if (function_exists('fsrep_pro_listing_child')) { $PageContent .= fsrep_pro_listing_child($ListingDetails->listing_id); }
if ($ListingDetails->listing_description != '') {
$PageContent .= '<div id="description" style="display:block;margin-top:-150px;"><h4 style="display:block;">'.fsrep_text_translator('FireStorm Real Estate Plugin', 'Description Label', 'Description').'</h4>';
$PageContent .= '<p>'.stripslashes(nl2br($ListingDetails->listing_description)).'</p>';
}
$PageContent .= '<p> </p></div>';
$Documents = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."fsrep_listings_docs WHERE listing_id = ".$ListingDetails->listing_id);
if (count($Documents) > 0) {
$PageContent .= '<h2>'.fsrep_text_translator('FireStorm Real Estate Plugin', 'Documents and Support Material Label', 'Documents and Support Material').'</h2>';
$PageContent .= '<p>';
foreach ($Documents as $Documents) {
$PageContent .= ''.str_replace($ListingDetails->listing_id,'',$Documents->document_name).'<br />';
}
$PageContent .= '</p>';
$PageContent .= '<p> </p>';
}
if ($ListingDetails->listing_virtual_tour != '' || $ListingDetails->listing_slideshow != '' || $ListingDetails->listing_video != '') {
$PageContent .= '<h2>'.fsrep_text_translator('FireStorm Real Estate Plugin', 'Videos and Slideshows Label', 'Videos and Slideshows').'</h2>';
$PageContent .= '<p>';
if ($ListingDetails->listing_virtual_tour != '') {
$PageContent .= ''.fsrep_text_translator('FireStorm Real Estate Plugin', 'Virtual Tour Label', 'Virtual Tour').'<br />';
}
if ($ListingDetails->listing_slideshow != '') {
$PageContent .= ''.fsrep_text_translator('FireStorm Real Estate Plugin', 'Slideshow Label', 'Slideshow').'<br />';
}
if ($ListingDetails->listing_video != '') {
$PageContent .= ''.fsrep_text_translator('FireStorm Real Estate Plugin', 'Video Label', 'Video').'<br />';
}
$PageContent .= '</p>';
$PageContent .= '<p> </p>';
}
Try to separate that in two parts using DIV.
Give float:left; to first DIV
You also need to define the width for the image section.Trying to put the image in a container like div or p tag and specified the width for the image section.
I have this little issue with the price form for my Joomla backend.
The default value is always "nothing", so I just need to set "Euro" as default (see screenshot).
I'm pretty newbie with PHP, so I can't do it by myself..
Here is the part of code that realizes this form:
$htmlPrice = '<div class="jomcomdevPriceRow">';
$htmlPrice .= '<div class="control-group" style="float: left; margin-right: 10px;">';
$htmlPrice .= '<label> '.JText::_('COM_JOMCOMDEV_FIELD_PRICE_NETTO').'</label><input type="text" name="' . $this->name.'[price_netto][]" id="' . $this->id . 'ValueNetto"' . ' value="" />';
$htmlPrice .= '</div>';
$htmlPrice .= '<div class="control-group" style="float: left; margin-right: 10px;">';
$htmlPrice .= str_replace("\n", '', '<label is="jform_featured-lbl"> '.JText::_('COM_JOMCOMDEV_FIELDSET_PRICE_GROUP').'</label>'.JHtml::_('select.genericlist', JHtml::_('jdcategory.options', 'com_jomestate.price', array('onlyroot' => 0)), $this->name.'[type_id][]',"", 'value', 'text', null, true));
$htmlPrice .= '</div>';
$htmlPrice .= '</div>';
I hope I'm clear enough. Thank you in advance.
Screenshot:
http://i.stack.imgur.com/2Ix39.png
UPDATE
Hmm, I don't know really where is configured this element. Here is full code, maybe I'm looking a wrong part..
defined( '_JEXEC' ) or die( 'Restricted access' );
class JFormFieldJdPrice extends JFormField
{
/**
* #var string The form field type.
* #since 11.1
*/
public $type = 'JdAddress';
/**
* Method to get the field input markup.
*
* #return string The field input markup.
*
* #since 11.1
*/
public function getInput()
{
$id = JRequest::getInt('id');
// if(empty($id)) {
// $html = '<div style="padding: 10px; margin: 10px 0;">';
// $html .= JText::_('COM_JOMCOMDEV_PRICEADD_NOID_INFO');
// $html .= '</div>';
// return $html;
// }
$htmlPrice = '<div class="jomcomdevPriceRow">';
$htmlPrice .= '<div class="control-group" style="float: left; margin-right: 10px;">';
$htmlPrice .= '<label> '.JText::_('COM_JOMCOMDEV_FIELD_PRICE_NETTO').'</label><input type="text" name="' . $this->name.'[price_netto][]" id="' . $this->id . 'ValueNetto"' . ' value="" />';
$htmlPrice .= '</div>';
$htmlPrice .= '<div class="control-group" style="float: left; margin-right: 10px;">';
$htmlPrice .= str_replace("\n", '', '<label is="jform_featured-lbl"> '.JText::_('COM_JOMCOMDEV_FIELDSET_PRICE_GROUP').'</label>'.JHtml::_('select.genericlist', JHtml::_('jdcategory.options', 'com_jomestate.price', array('onlyroot' => 0)), $this->name.'[type_id][]',"", 'value', 'text', null, true));
$htmlPrice .= '</div>';
$htmlPrice .= '</div>';
$link = JURI::root()."index.php?option=com_jomcomdev&format=raw&task=ajax.price&name=first&id=";
$runScript = "
window.addEvent('domready', function() {
var options = {htmlPrice: '".$htmlPrice."', link: '".$link."', selector: $$('#".$this->id."')};
Comdev.price.init(options);
});
";
$document = JFactory::getDocument();
$document->addScriptDeclaration($runScript);
JText::script('COM_JOMCOMDEV_JS_BUTTON_ADD');
JText::script('COM_JOMCOMDEV_JS_BUTTON_DELETE');
JText::script('COM_JOMCOMDEV_JS_BUTTON_OPTION');
JText::script('COM_JOMCOMDEV_FIELD_PRICE_NETTO');
$html = '';
$html .= '<div id="'.$this->id.'">';
if(!empty($id)) {
$data = Main_Price::get($id, (string) $this->element['extension']);
foreach($data AS $d) {
$html .= '<div class="jomcomdevPriceRow">';
$html .= '<div class="control-group" style="float: left; margin-right: 10px;">';
$html .= '<label is="jform_featured-lbl"> '.JText::_('COM_JOMCOMDEV_FIELD_PRICE_NETTO').'</label><input type="text" name="' . $this->name.'[price_netto][]" id="' . $this->id . 'ValueNetto"' . ' value="'.$d->price_netto.'" />';
$html .= '</div>';
$html .= '<div class="control-group" style="float: left; margin-right: 10px;">';
$html .= '<label is="jform_featured-lbl"> '.JText::_('COM_JOMCOMDEV_FIELDSET_PRICE_GROUP').'</label>'.JHtml::_('select.genericlist', JHtml::_('jdcategory.options', 'com_jomestate.price', array('onlyroot' => 0)), $this->name.'[type_id][]', 'value', null, 'text', $d->type_id, true);
$html .= '</div>';
$html .= '<div class="control-group" style="padding-top: 17px;">';
$html .= '<label></label>'.JText::_('COM_JOMCOMDEV_JS_BUTTON_DELETE').'';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="clr"></div>';
}
}
$html .= '</div>';
return $html;
}
}