How to make Bootstrap Tab dynamic PHP? - php

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++;
}

Related

if checkbox checked enable his textarea

in this php code i have foreach loop create textarea with checkbox for each statement
i wanna to enable textarea if his checkbox is checked
but they have same id
<?php
foreach($Arows as $row){
echo '<tr class="row">
<th class="col-sm-12"><h4>'.$row['Type_A'].'</h4></th>
</tr>';
$stmt3 = $con->prepare("SELECT * FROM sous_analyse WHERE Id_A =".$row['Id_A']);
$stmt3->execute();
$SArows = $stmt3->fetchAll();//Analyse rows
foreach($SArows as $Srow){
echo '<tr class="row">
<td class="col-sm-4">'.$Srow['Parameter'].'</td>
<td class=" col-sm-5"><input type="text" class="form-control col-xl-12 border-secondary" name="Fonctionnalite" placeholder="RESULTATS" required=""></td>
<td class="col-sm-3 text-center">'.$Srow['Normal'].'</td>
</tr>';
}
echo '<tr class="row">
<th class="col-sm-12">
<div class="input-group">
<span class="input-group-addon form-check">
<span class="checkbox-custom checkbox-default">
<input type="checkbox" class="icheckbox-grey" id="inputUnchecked" name="inputUnchecked">
<label for="inputUnchecked"></label>
</span>
</span>
<textarea class="form-control" id="textareaDefault" rows="3" style="margin-top: 0px; margin-bottom: 0px; height: 60px;" disabled></textarea>
</div>
</th>
</tr>';
}
?>
i use this script but is working in first textarea
<script >
$(document).ready(function() {
$("#inputUnchecked").on('click', function() {
if($(this).is(':checked')){
$("#textareaDefault").prop('disabled',false);
} else {
$("#textareaDefault").prop('disabled',true);
}
alert("fdg");
})
});
</script>
Expanding on my comment, you will want to adjust your PHP. This is easily done with a counter ($c).
<?php
foreach($Arows as $row){
$html = "";
$html .= '<tr class="row">'."\r\n";
$html .= '<th class="col-sm-12"><h4>'.$row['Type_A'].'</h4></th>'."\r\n";
$html .= '</tr>'."\r\n";
$stmt3 = $con->prepare("SELECT * FROM sous_analyse WHERE Id_A =".$row['Id_A']);
$stmt3->execute();
$SArows = $stmt3->fetchAll();
$c = 1;
foreach($SArows as $Srow){
$html .= '<tr class="row">'."\r\n";
$html .= '<td class="col-sm-4">'.$Srow['Parameter'].'</td>';
$html .= '<td class=" col-sm-5"><input type="text" class="form-control col-xl-12 border-secondary" name="Fonctionnalite" placeholder="RESULTATS" required=""></td>';
$html .= '<td class="col-sm-3 text-center">'.$Srow['Normal'].'</td>';
$html .= '</tr>';
}
$html .= '<tr class="row">';
$html .= '<th class="col-sm-12">';
$html .= '<div class="input-group">';
$html .= '<span class="input-group-addon form-check">';
$html .= '<span class="checkbox-custom checkbox-default">';
$html .= '<input type="checkbox" class="icheckbox-grey" id="inputUnchecked-$c" name="inputUnchecked">';
$html .= '<label for="inputUnchecked-$c"></label>';
$html .= '</span></span>';
$html .= '<textarea class="form-control" id="textareaDefault-$c" rows="3" style="margin-top: 0px; margin-bottom: 0px; height: 60px;" disabled></textarea>';
$html .= '</div></th></tr>';
echo $html;
$c++;
}
?>
Your JavaScript can then use the ID since it is unique or can simply be relative to nearby elements.
$(function() {
$("[id^='inputUnchecked-']").on('click', function() {
if($(this).is(':checked')){
$(this).parent().parent().find("[id^='textareaDefault-']").prop('disabled',false);
} else {
$(this).parent().parent().find("[id^='textareaDefault-']").prop('disabled',true);
}
alert("fdg");
})
});

Foreign Key In Php to get data from another table

function show_username($connect)
{
$output = '';
$query = "SELECT * from users";
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<option value="'.$row["id"].'">'.$row["name"].'</option>';
{
}
return $output;
}
function show_offer($connect)
{
$output = '';
$query = "SELECT * FROM add_offer ORDER BY id DESC";
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<div class="col-md-3 col-sm-4 col-lg-6">';
$output .= '<div class="panel panel-default">';
$output .= '<div class="panel-body">';
$output .= '<div style="padding:1px;float:left;font-weight:bold;">'.$row["part_no"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["make"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["date_code"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["qty"].'</div>';
$output .= '<br>';
$output .= '<div style="float:left;font-size:9px;">'.$row["time"].'</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
}
echo $output;
}
<div class="container">
<div class="row">
<div class="col-lg-offset-3 col-lg-6">
<div class="panel">
<div class="panel panel-default" style="border: 1px solid #66512c;">
<div class="panel-heading" style="background-color: #66512c;color: white;">
Market Offers
</div>
<div class="panel-body" style="padding: 0px;padding-left: 5px;border-bottom: 1px solid #66512c;">
<div class="nav nav-pills nav-stacked">
<select name="category" id="user" class="form-control">
<option selected="" value="" class="form-control">All User Offers</option>
<?php echo show_username($connect); ?>
</select>
<div class="panel panel-body" id="show_offer">
<?php echo show_offer($connect);?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3"></div>
</div>
<script>
$(document).ready(function(){
$('#user').change(function(){
var user_id = $(this).val();
$.ajax({
url:"load_data.php",
method:"POST",
data:{user_id:user_id},
success:function(data){
$('#show_offer').html(data);
}
});
});
});</script>
<?php
//load_data.php
$connect = mysqli_connect("localhost", "root", "", "customer");
$output = '';
if(isset($_POST["user_id"]))
{
if($_POST["user_id"] != '')
{
$query = "SELECT * FROM add_offer WHERE user_id = '".$_POST["user_id"]."' ORDER BY id DESC";
}
else
{
$query = "SELECT * FROM add_offer ORDER BY id DESC";
}
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<div class="col-md-3 col-sm-4 col-lg-6">';
$output .= '<div class="panel panel-default">';
$output .= '<div class="panel-body">';
$output .= '<div style="padding:1px;float:left;font-weight:bold;">'.$row["part_no"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["make"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["date_code"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["qty"].'</div>';
$output .= '<br>';
$output .= '<div style="float:left;font-size:9px;">'.$row["time"].'</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
}
echo $output;
}?>
In this above code I have used functions to take data from 2 seperate table and I want to display the table in the following format as
name from users table
part_no,make,date_code,qty from add_offers table
the image shows my output market_offers page
I want the data not to be selected by dropdown but has to display whole data as first with name from users table and followed by users part_no from add_offers table.
Also the timestamp display as 2018-03-22 12.40.55 which i want as 22-03-2018 12.40.55
You've to change your code as bellow:
function show_username($connect)
{
$output = '';
$query = "SELECT * from users order by id asc";
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<option value="'.$row["id"].'">'.$row["name"].'</option>';
{
}
return $output;
}
function show_offer($connect)
{
$output = '';
$user_query = "SELECT * from users order by id asc";
$user_res = mysqli_query($connect, $user_query );
$user_row = mysqli_fetch_array($user_res);
$query = "SELECT * FROM add_offer where user_id = ".$user_row['id']." ORDER BY id DESC";
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<div class="col-md-3 col-sm-4 col-lg-6">';
$output .= '<div class="panel panel-default">';
$output .= '<div class="panel-body">';
$output .= '<div style="padding:1px;float:left;font-weight:bold;">'.$row["part_no"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["make"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.date('d-m-Y H:i:s',strtotime($row["date_code"])).'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["qty"].'</div>';
$output .= '<br>';
$output .= '<div style="float:left;font-size:9px;">'.$row["time"].'</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
}
echo $output;
}
Html Code:
<div class="container">
<div class="row">
<div class="col-lg-offset-3 col-lg-6">
<div class="panel">
<div class="panel panel-default" style="border: 1px solid #66512c;">
<div class="panel-heading" style="background-color: #66512c;color: white;">
Market Offers
</div>
<div class="panel-body" style="padding: 0px;padding-left: 5px;border-bottom: 1px solid #66512c;">
<div class="nav nav-pills nav-stacked">
<select name="category" id="user" class="form-control">
<option selected="" value="" class="form-control">All User Offers</option>
<?php echo show_username($connect); ?>
</select>
<div class="panel panel-body" id="show_offer">
<?php echo show_offer($connect);?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3"></div>
</div>
Java Script Code:
<script>
$(document).ready(function(){
$('#user').change(function(){
var user_id = $(this).val();
$.ajax({
url:"load_data.php",
method:"POST",
data:{user_id:user_id},
success:function(data){
$('#show_offer').html(data);
}
});
});
});</script>
PHP Code:
<?php
//load_data.php
$connect = mysqli_connect("localhost", "root", "", "customer");
$output = '';
if(isset($_POST["user_id"]))
{
if($_POST["user_id"] != '')
{
$query = "SELECT * FROM add_offer WHERE user_id = '".$_POST["user_id"]."' ORDER BY id DESC";
}
else
{
$query = "SELECT * FROM add_offer ORDER BY id DESC";
}
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<div class="col-md-3 col-sm-4 col-lg-6">';
$output .= '<div class="panel panel-default">';
$output .= '<div class="panel-body">';
$output .= '<div style="padding:1px;float:left;font-weight:bold;">'.$row["part_no"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["make"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["date_code"].'</div>';
$output .= '<div style="padding:1px;float:left;">'.$row["qty"].'</div>';
$output .= '<br>';
$output .= '<div style="float:left;font-size:9px;">'.$row["time"].'</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
}
echo $output;
}?>

How to take two div side by side in wordpress

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.

Get individual form collection elements ZF2

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;
}

PHP Change default value for Select list

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;
}
}

Categories